How to stabilize PHP response time when dealing with multiple concurrent requests?

I am building a PHP application with an API that can respond very quickly (within 100ms) to all requests and should be able to handle up to 200 requests per second (requests are in JSON and requests require DB lookup + save every time). My code is fast enough (very consistently around 30ms) for single requests, but as soon as it has to respond to multiple requests per second, response times start jumping all over the place.

I don't think this is a memory issue (PHP memory limit is limited to 128MB, and code memory usage is only about 3.5MB) or a MySQL issue (code before any DB query is more likely to bottleneck than bit that interacts with the database).

Since time is so important, I need to get the response time as quickly as possible. So my question is, are there any simple tweaks I can make (for php.ini or Apache) to stabilize PHP response times when handling multiple concurrent requests?

+3


source to share


1 answer


One of the slowest things (easiest to fix) in my experience on a server in terms of bottleneck will be your filesystem and hard drives. I think speeding this up will help in all other areas. This way you can, for example, update the hard drive where your httpdocs and database are located. For example, you can install it on an SSD drive. Or even make a RAM disk and put all the files on it.

Alternatively, you can configure your database to work with a memory storage engine. (Related information here )

Of course, you'll need a lot of physical memory for all this. It is also important to note that your web hosting you received is shared, then you will have shared memory issues.

Tune Mysql

Tune Apache



PHP performance tuning

Get Zend Optimizer enabled or see APC or eAccelerator

Here's some basic LAMP setup tips from IBM

Here's a slideshow with good advice

+1


source







All Articles