Welcome Guest, Not a member yet? Register   Sign In
blocking vs async using guzzle

(This post was last modified: 08-10-2018, 01:34 AM by richb201.)

I am implementing code to write out a copy of my collected data to Amazon S3. S3 uses Guzzle and allows the calls to send the data either sync or async (promises). If each instance of my php program is truly a separate process, then synch should not be a problem. However, if these are really being handled by a single multi thread process then I must do async. 

Does anyone have a deep understanding of how Apache and php interact or can you point me to a white paper? Clearly synch is much easier to implement.
proof that an old dog can learn new tricks


Here's video of Rasmus explaining how multi-threading works on PHP.

For what I understand from your description, sync or async wouldn't make much difference, because your PHP process on server is running throughout all the subcalls to AWS API.

If you are worried that this once back-end call will take too much resource away from your normal visitors, you should move it to second server instance that does the heavy duty tasks and keep the first server to only handle front end web requests.

Thanks. That really cleared up things. Part of what I am doing is to keep a copy of the data logs on S3, and thus not on the mysql database which is running on my same server. That is the reason that I am sending it over to s3. But I am also keeping a local copy of the data in my same database so that users can browse it "realtime". Kind of defeats the purpose? Perhaps the answer is to only keep 2 weeks of current data on my local mysql and if the user wants their data, I can email it to them. I just managed to get the writing of data to the s3 working late last night as a proof of concept. Did I mention that I don't have any users yet? Smile.

Do you know of any automatic way to delete records from a mySQL server when they get aged?
proof that an old dog can learn new tricks


You could create an independent cron tab house keeping job that runs either weekly or monthly and deletes aged records.

Theme © iAndrew 2016 - Forum software by © MyBB