1

There is a lot of evidence that reusing a curl handle is very beneficial and allows you to utilize persistent (keep-alive) connections when making multiple requests to the same server.

I have an RTB server that never requests the same server more than once during a single script execution, but hits the same servers nearly every separate script execution.

Is there any way to reuse a curl handle from one execution to the next? Maybe this is already happening? I don't see how it would be, but I'm honestly not totally sure how I would test it to be sure anyway.

dtbarne
  • 8,110
  • 5
  • 43
  • 49
  • 1
    In short, no. Not if the PHP process ends. There are some creative solutions but it would require a long running PHP process and some kind of IPC mechanism. Basically you would have some kind of PHP daemon process that would hold the reference to the curl handles in memory and you would pass work from the incoming request to the long running process using some sort of IPC. I am not aware of any out-of-the-box solutions, but it is definitely possible. – Alex Barker Nov 27 '19 at 01:30
  • 1
    Yeah, that's what I am afraid of. I envisioned something like that too, where there's a long running background process that the separate requests make use of. I'll keep this open in case anyone else has any better (ie. easier) ideas. :) – dtbarne Nov 27 '19 at 21:25

0 Answers0