PHP/MySQL: de T2000 as a heavy SAMP web server

Publish date: 2024-06-13
PHP/MySQL: T2000 as a heavy SAMP web server

In this first part of our T2000 review, we look at the T2000 as a heavy Apache, MySQL and PHP web server (or SAMP web server). You do not buy a T2000 to offer some basic web services or to serve up some static HTML.

There are two ways that the T2000 could be useful as a web server. The first one is to use Solaris zoning (a.k.a. "Solaris containers") techniques to run a lot of light/medium web servers in parallel virtual zones. As virtualisation is still something that requires quite a bit of expertise, and we didn't have much experience with Solaris Zones, we decided to test the second scenario.

As a side note, the T1 has a built-in support for a hardware called Hypervisor (which is a first for Sparc), which might make virtualisation quite a bit faster. It also makes OS support easier (once your OS can support running inside the Hypervisor, there'd be little porting left to do), except for new features. Basically, the Hypervisor virtualises the chipset, giving a consistent view to the OS. Sun is helping to make sure that Linux and BSD gets ported to the T1.

Back to our web server testing. The second scenario is a heavy web server, which gets a lot of traffic on dynamically generated content that requires quite a bit of number crunching.

We have two real world examples: one using JSP and Sybase, and the other one using PHP/MySQL. In this article, we like to introduce you to the first example.

The PHP test script retrieves hourly-stored weather information out of a MySQL database, which can be overviewed by month. An 'opening page' displays all months that are stored in the database, and if you open a 'detail page', the month you have selected is submitted by query string parameters.

On that new opened page, you see the following information for that month:

Bert Devriese, who wrote the PHP script, explains how the script behaves: "When the page is requested, first thing the script does is checking if all $_GET variables, such as 'm' and 'j' are set. If somebody requests the page without these $_GET variables, the script will not continue because it has insufficient parameters to continue.

Next thing that happens is the 'cache-file check'. I haven't used any type of PEAR class, or other frameworks that support caching, to enable caching in the weather-script. I simply check if the cache file exists (the cache file contains the regular HTML output that the browser of the client normally would receive), and if it's not older than one minute. If so, the file will be included, and the php 'exit' command will be executed so that the script thinks that it has 'ended' and the output will be sent to the browser.

If the cachefile does not exist, or if it's older than one minute, the script will simply continue, but the ob_start() function, to start 'output-buffering', will be executed. All regular scripts and several MySQL queries will be executed, and at the end of the file, a new file will be created with fopen($file,'w') (the 'w' makes sure that if the file already exists, it just will be blank and it will seem as if you're writing to a 'new' file. If the file does not exist already, it will be created). When the script ends, the output buffer contents will be retrieved with ob_get_contents(), and all this output will be written to the new cache-file with fwrite(). At the end, ob_end_flush() will flush the output buffer contents to the browser of the client..."

He included a nice diagram for us to make the process clearer.

For benchmarking, httperf was used in conjunction with autobench, a Perl script written by Julian T. J. Midgley, designed to run httperf against a server several times, with the number of requests per second increasing at each iteration. The output from the program enables us to see exactly how well the system being tested performs as the workload is gradually increased until it becomes saturated. In each case, the server was benchmarked with 5 requests per connection.

ncG1vNJzZmivp6x7orrAp5utnZOde6S7zGiqoaenZH56g5ZobQ%3D%3D