CodeIgniter Forums
blocking vs async using guzzle - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: blocking vs async using guzzle (/showthread.php?tid=71401)



blocking vs async using guzzle - richb201 - 08-10-2018

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.


RE: blocking vs async using guzzle - Pertti - 08-10-2018

https://www.youtube.com/watch?v=OEMuHy5Srk8

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.


RE: blocking vs async using guzzle - richb201 - 08-10-2018

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?


RE: blocking vs async using guzzle - php_rocs - 08-10-2018

@richb201,

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