I'm creating a new web application in PHP and I'd like to create it in a way that scales well over time.
What should or shouldn't I do? I know that I should cache, but what should I cache and how? What else can I do for the website to remain loading rapidly?
So what actually do you mean by scalability? It's the ability of a website or web application to grow with the expanding business needs of the firm. PHP is quite scalable and works well with various frameworks like Symfony, Codeigniter, Zend, CakePHP and many more.
It is the capability of a system either for automatically raise up or lower down the use of its resources (CPU, memory, etc.) depending on the level of demand required from it.
Note: this wasn't written by me, but by Snorkel from YC news
Here's a short list:
Varnish
or other reverse proxy cache.APC
or XCache
PHP opcode cache.memcached
, redis
, file caches, and application-level caches (ie. global vars)Apache
, MySQL
, and Linux
have lots of settings that affect performance, especially the timeout settings ought to be turned down.strace
, top
, iostat
, vmstat
, and query logging to see which layer is using the most time and resourcesMost of the time a PHP slows down because each PHP process is blocked waiting for I/O from some other layer, either a slow disk, or overloaded database, or hung memcached process, or slow REST API call to a 3rd party service ... often just strace'ing a live PHP process will show you what its waiting for ... in short, blocking I/O slows down everything. The key to going faster is:
Scaling to several front-ends require also to replicate the root of your website and its dynamic content.
GlusterFS is a nice add, however it is unclear to me how well it scales up. Another alternative is Lsyncd. Other alternatives may include GIT for the code and a CDN for the dynamic content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With