02
Jul
Progress on C++ Web Server / Web Framework
By Joseph Montanez
0 Comment

UPDATE:
Download 0.0.1 Alpha Source

Languages have their marks and roles in programming, but nothing is as versatile and fast as C/C++ code. But their is a major lacking in c++ web frameworks so I've been working on a simple framework. Its still in its early stages and only works on linux (due to network interface). I created a sample,against the LAMPP stack, using a very simple php / c++ request. Using my framework / server it was a drop in the bucket. Apache + Php was wide in its response. Between 4-22 seconds but 6-7 was its average. However with G3D::WebServer it was a constant ~1 second. I would try at a higher concurrency but Apache was unable to keep up. If anyone is interest just contact me.

Why Even Do this?

I run on a Virtual Server, getting the Whole LAMPP Stack running on 128 MB ram is hard... So I've set out to make a very light webserver with a simple framework to build on. Put that with just sticking to MySql's MyISAM database engine and I could build a high performance site with 32 MB.

G3D WebServer

14-15% Cpu Per Thread * 1 Threads 14-15% CPU for ~1 Seconds 1 KB Memory Usage Serve 10000 pages to 500 people 0.998 seconds

Apache + Php

5-8% Cpu Per Thread * 10 Threads 50-80% CPU for ~7 Seconds 66 MB Memory Usage Serve 10000 pages to 500 people 6.819 seconds
class HomeController : public WebController {
public:

    void get() {
        this->repsonse->body.append("\
            <html>\
            <head>\
	            <title>XAMPP</title>\
            </head>\
                <body>\
                " + this->request->get("asdfasdf") + "\
                <form action='' method='post'>\
                <input type='hidden' name='asdfasdf' value='dsfasdfasdf' />\
                <input type='submit' name='submit' value='Push' />\
                </form>\
            </body>\
            </html>\
        ");
    }
};
<html>
<head>	
    <title>XAMPP</title>
</head>
<body>
    <?php echo $_POST['asdfasdf'] ?>
    <form action="" method="post">
    <input type="hidden" name="asdfasdf" value="dsfasdfasdf" />
    <input type="submit" name="submit" value="Push" />
    </form>
</body>
</html>
joseph@joseph:~$ ab -c 500 -n 10000 http://localhost:8181/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        G3D::WebServer/0.1a
Server Hostname:        localhost
Server Port:            8181

Document Path:          /
Document Length:        206 bytes

Concurrency Level:      500
Time taken for tests:   0.998 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      4850000 bytes
HTML transferred:       2060000 bytes
Requests per second:    10022.14 [#/sec] (mean)
Time per request:       49.890 [ms] (mean)
Time per request:       0.100 [ms] (mean, across all concurrent requests)
Transfer rate:          4746.81 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0      12
Processing:     0    1   5.9      0     226
Waiting:        0    0   5.9      0     226
Total:          0    1   5.9      0     226

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      1
  75%      1
  80%      1
  90%      1
  95%      1
  98%      2
  99%      4
 100%    226 (longest request)
joseph@joseph:~$ ab -c 500 -n 10000 http://localhost/bench.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.2.11
Server Hostname:        localhost
Server Port:            80

Document Path:          /bench.php
Document Length:        207 bytes

Concurrency Level:      500
Time taken for tests:   6.819 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      4830966 bytes
HTML transferred:       2070414 bytes
Requests per second:    1466.54 [#/sec] (mean)
Time per request:       340.938 [ms] (mean)
Time per request:       0.682 [ms] (mean, across all concurrent requests)
Transfer rate:          691.88 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   39 103.8     40    3000
Processing:    12  238 1001.4     50    6795
Waiting:        3  229 1002.7     43    6793
Total:         26  277 1005.0     93    6816

Percentage of the requests served within a certain time (ms)
  50%     93
  66%    107
  75%    115
  80%    119
  90%    138
  95%    153
  98%   4070
  99%   6799
 100%   6816 (longest request)

« Back to my notebook
Next Note > < Previous Note
Comment Pages: 1


esign