views:

188

answers:

4

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?

+10  A: 

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.

Julien Tartarin
Agreed. You can only do so much from the software side before you have to start looking at hardware.
ryeguy
+3  A: 

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.

Ólafur Waage
Hello, My Code is basically only getting HTML from Memcached and displaying it to user.
tomaszs
Then you should note that, since you tag it as PHP and talk about a PHP application
Ólafur Waage
@Olafur Sorry if I was not precise in my question. But as you written I asked my code again for sure. So thanks - it could be a solution.
tomaszs
Even if the page is simple, you might learn something from the profiler. There are many dark corners, where you can do micro-optimisations.
troelskn
+2  A: 

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.

troelskn
Http header ! check that !
Antoine Claval
A: 

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

poiuyttr