I was surprised to learn today that PHP is used widely in high-traffic websites.
I always thought that PHP is not strong in terms of performance, being a dynamic, scripting language (e.g. compared to statically typed, compiled language like C/Java/C# etc.).
So how come it performs so well?
PHP has been designed ground up to efficiently handle HTTP traffic, there is less to build in comparison to building using other compiled languages.
The very sensible tips that can handle 30,000 concurrent users per web server: Use PHP's APC feature. APC is opcode cache that is "really a requirement in order for a website to have a chance at performing well."
In its simplest form, PHP is a server-side scripting language that is embedded in HTML. PHP allows web developers to create dynamic content and to interact with databases. PHP is known for its simplicity, speed, and flexibility — features which have made it a cornerstone in the web development world.
High traffic website is one getting 500,000 page views and above per month. The traffic should be constant each month. High traffic websites are countable, less than 200,000 worldwide. To achieve this amount of traffic, you have to own an authority site.
What you'll usually find is that it's not as slow as you think. The reason a lot of sites are slow is because the hosts are overloaded.
But one primary benefit of PHP over a compiled language is ease of maintenance. Because PHP is designed from the ground up for HTTP traffic, there's less to build than with most other compiled languages. Plus, merging in changes becomes easier as you don't need to recompile and restart the server (as you would with a compiled binary)...
I've done a considerable amount of benchmarks on both, and for anywhere under about 50k requests per second (based upon my numbers) there really isn't a significant gain to using a compiled binary (FastCGI). Sure, it's a little faster using compiled C, but unless you're talking Facebook level traffic, that's not really going to mean significant $$$. And it's definitely not going to offset the relatively rapid rate of development that PHP will afford in comparison to using C (which more than likely will require many times the code since it's not memory managed)...
PHP, if properly written can be quite scalable. The limiting factors are typically in your database engine. And that's going to be a common factor no matter what technology you use...
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