I have nginx+php-fpm+apc setup. No DB. In data folder i have a simple php script that when called with filename parameter checks if the file exists, if it does then it gives it away, if not then it downloads it in the same folder and then gives it away. The speed is very important, now it takes 70ms to output the file in browser.
The files are images with size 1-2kb. With this rate in some months there will be some thousands of images in that folder. And this script will be called tens of times per second(maybe more). So im afraid that the server will start to struggle.
Can you advice me :
-Nginx tweaks
-System tweaks
-Should i run some kind of HDD maintenance now and then?
What else would you recommend in this situation?
RAM: 386MB (upgradable) CPU: Xeon E5506 @ 2.13GHz CentOS 6
Update #1 An interesting idea: Don't have PHP check if a file exists -- have nginx try to serve the file directly, then fall back to PHP as a 404 handler. If you leave nginx to do its thing, it should easily serve ~1000 2kb images/sec with no tweaking.