How to improve PHP performance?

2020-06-23 09:07发布

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?

4条回答
仙女界的扛把子
2楼-- · 2020-06-23 09:55

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.

查看更多
Anthone
3楼-- · 2020-06-23 10:00

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.

查看更多
Fickle 薄情
4楼-- · 2020-06-23 10:04

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

查看更多
爷的心禁止访问
5楼-- · 2020-06-23 10:08

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.

查看更多
登录 后发表回答