3 times speed increase with static pages

3 times speed increase with static pages

Internet was born from static pages. People were creating websites with emacs and vi. With the increased popularity of scripting languages and open-source databases like MySQL and Postgresql, more and more developers started to use these advanced tools.

CMS – Content Management Systems systems were built. They made our lives much easier. Instead of altering file contents with the text editor, the user can simply go to the website admin panel and change page from there.

The speed of loading page generated in PHP with MySQL is much slower than a static page. In addition, on every page request, CMS can generate tens or even hundreds of database requests.

With the advances of new web technologies like Jquery and HTML5, we have a chance to get back to the roots. We can create static websites that behave the same as dynamic ones.

I would like to show you some benchmarks.

In my test, I will fetch two small test pages. One with static content and another one generated with PHP and MySQL.

Contents of test.html file:

<html>
<head>
<title>hello world</title>
</head>
<body>
<h2>Hello world!</h2>
</body>
</html>

Contents of test.php file:

<html>
<head>
<title>hello world</title>
</head>
<body>
<?php
$handler =  mysql_connect('127.0.0.1', 'user', 'password');
$result = mysql_query("SELECT 'Hello World!'");
$row = mysql_fetch_row($result);
print "<h2>$row[0]</h2>\n";
?>
</body>
</html>

In my test, I used the “ab” command to test web application speed. It stands for Apache Bench – a small application to perform a quick test for website speed.

To test static page speed I use the following command:

ab -c 100 -n 10000 http://website.com/test.html

To test dynamic page speed I use the following command:

ab -c 100 -n 10000 http://website.com/test.php

In this test, I got the following result.

Static pages are at least 3 times faster than dynamic pages generated with PHP and MySQL.

In my production server, at average, ab was able to fetch almost 15k requests per second for test.html static page and 5k requests per second for the test.php dynamic page.

Feel free to leave your benchmark results here.

About the author

Yuli Stremovsky
Yuli StremovskyParanoid Security Guy
For the past 15 years I’ve been leading the evolution of startups and enterprises to achieve the highest level of security and compliance. Throughout my career I’ve been a Cyber Security expert and advanced solutions architect with many years of hands on experience both on offensive and defensive side. Knowledgeable at the highest level in application development, networking, data and databases, web applications, large scale Software as a Service solutions, cloud security and blockchain technologies.

I’ve been working with CISO’s of international enterprises, helping them set Information Security strategy, and overseeing the implementation of these recommendations. As part of these projects, I’ve been assisting companies to achieve compliance in GDPR, PCI, HIPAA and SOX.

Among my credits, I was a founder of a database security company GreenSQL/Hexatier which was acquired by Huawei and I’ve co-founded Kesem.io, Secure multi-signature Crypto wallet.

Specialties: Software and cloud architecture, Compliance (GDPR, HIPAA, PCI, SOX), blockchain technologies, software development, secure architectures, project management and low level research.