i have a php script that resize image to three different resolutions on upload. When i upload a image it resizes it to 300*300, 80*80, 800*800 and also saves the original file.
The script that i use is the following link https://github.com/blueimp/jQuery-File-Upload/blob/master/example/upload.php
the following images is the system monitor of the server. The first two spikes of CPU history the resize of the image that takes place when the file is uploaded individually. The following are the files that are uploaded from a queue.
During this upload the server couldn't handle other requests. i cannot able to access other pages at that time. either the page loads half or doesn't load at all or the page loads once the upload is complete.
i need immediate solution to this problem. how to overcome this issue. i have to full for the server. is there any pluggin for apache for image resize or is there a problem with the code.
Even if resizing an image took 100% of CPU during a minute, it would still be possible to do other requests: you are using a multi-processes server on a multitasking operating system (and probably with multiple cores too).
However, when you start a PHP session, the session is locked: other requests trying to use the same session have to wait until the first request ends.
This is why you can't do concurrent requests while the image is being resized.
You have to close your session before doing long processing (and eventually re-open it after that).
So, this should fix your problem:
session_write_close();
resize_the_image();
session_start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With