Process instace api - gateway timeout error

I am trying to call following engine rest API and I am getting gateway timeout after 3 minutes on peak hours when system is in use.

{{camunda_url}}/process-instance/variables=workflowPendOrTerminateAction_eq_pend123

We have around 5K instance running and 40-50 instance variables per instance and search is needed across all running instances by suppling some variable value. we tries post method as well but same issue.

Can we do something to avoid this error?