504 error and understanding PHP logs
This is a performance issue, and/or some timeouts that are set too low (in apache)
You could use a php profiler to figure out what is slow in PHP code: Xdebug, Xhprof, Z-Ray and Prefix.
Check also resource utilization.
Edit 1: The long string is not a variable, it is missing the equals. It is part of query string of the URL. Could be something like a session cookie, and it depends on your php application how is it used.
About php-fpm pools allows to group multiple workers that have the same config and same listener. You could use pools if you have multiple users and you want to separate the permission each pool has, and under which user is running.
When you see spikes you have to know if it is about bandwidth, number of requests, number of sessions, etc. And those spikes might not be related to performance issues.