Tom Smykowski
Tom Smykowski

Reputation: 26119

How to improve PHP performance?

I've created PHP application for Facebook. It uses MySQL, Memcached and works on Lighttpd on Centos 2,6 Ghz and 2 GB RAM.

it's basically one PHP file that after first run is cached and every next time it's served in 0,8 ms directly from Memcached.

What more can I do to shorten this time?

Upvotes: 3

Views: 1203

Answers (4)

poiuyttr
poiuyttr

Reputation: 110

Do you have a php script which gets data from memcached and displays them, or the web server itself gets data, directly from memcached?

I don't know if lighthttpd can display page directly from memcached, but i know nginx can do this google for ngx_http_memcached_module

Upvotes: 1

troelskn
troelskn

Reputation: 117595

You can put a http-proxy and load balance to multiple servers. Most http-proxies can double as a cache, which can take load off the application.

Also, make sure that you send the proper http headers, so that your pages are client-side cacheable. This may reduce the number of requests, as the clients will reuse their cached version.

Upvotes: 2

Ólafur Waage
Ólafur Waage

Reputation: 70001

Run XDebug and run the profiler. There you can see if you have any functions that take an abnormal length of time.

I recommend using a program that reads those logs. Like kcachegrind etc.

BTW, when you enter profiler country, there's no turning back.

Upvotes: 3

Julien
Julien

Reputation: 525

Once you get to 0.8 ms, I'm not sure you can go any lower.

However, you can set up multiple servers to handle many concurrent requests (with a common memcached). You will then be able to scale very high by simply adding a new server when you reach limits.

Upvotes: 11

Related Questions