[Mono-dev] Unix-sockets & Mono.WebServer.FastCgi

SirNoSkill quandary82 at hailmail.net
Wed Feb 19 07:44:22 UTC 2014


I don't usually do performance tests on mono as such.

I'm not terribly interested in how good or bad a particular
component/routine performs.

Usually it's fast enough for my purposes.



I just perform load tests, mainly to see if the system is stable and
fast enough, especially under multiple concurrent users.

I've always found that particularly interesting and useful, as it
quickly uncovers the most severe multi-threading or performance
related bugs in any code.

And in the end, stability under higher load than 1 concurrent users is
what really matters most, and is what's tested least.



I had benchmarked xsp-2.10.2 from the stable sources several times, it
never survived the attempt without crashing ;)



I just benchmarked it now, at 6:40 in the morning, no crash, doesn't
look bad ;)

Oh, and haha, as a side-remark, LoadImpact doesn't seem to be verifying
if you're the test-target server owner - ouch, ouch ouch, grossly
negligent.

Benchmark results are here:

[1]https://loadimpact.com/load-test/www.daniel-steiger.ch-b67fbd0a9e513
bdb6d1cfda8f044e082

That basically is a benchmark of /Home/Index.



If you want to know how that compares to a plain and simple webserver,
I ran a benchmark on

[2]http://88.84.21.77/

that's plain and simple nginx (nginx version: nginx/1.4.1) there on the
same server.

And those are the results:

[3]http://loadimpact.com/load-test/88.84.21.77-a7f4b192a3435b38405e2751
299f8d05







FYI, the version of mono on the server is:

3.2.7 (master/45d5758 Tue Dec  3 11:57:34 CET 2013)

ASP.NET Version: 4.0.30319.17020



xsp (and therefore fastcgi-server)

Tue Feb 4, 21:36 CET 2014







Opps, looks like that happiness was premature.

I thought that /Gallery/Index would probably make for a more
interesting benchmark, since all /Home/Index does is add a few strings
to a list, and a little razor syntax generation.

Now I get a HTTP 502 bad gateway .

Here the test results, showing the problem/crash between 06:59 and
07:00 o'clock

[4]http://loadimpact.com/load-test/daniel-steiger.ch-39452482e4a26c612d
067e1582addb99



Looks like the fastcgi-mono-server4 process is gone.



/etc/init.d/monoserve.sh stop

yields: mono server is not running



Restarted it.

On the upside, that's a really entertaining graph - server crash as
graph ;)

Looks like something isn't as thread-safe as it should be,

My guess is that this is probably related to image re-sizing, but might
as well by my own code's fault.







landscape-sysinfo

  System load:  0.03                         Processes:             126

  Usage of /:   11.2% of 105.74GB    Users logged in:       1

  Memory usage: 5%                        IP address for p32p1:
192.168.1.2

  Swap usage:   4%                          IP address for virbr0:
192.168.122.1







Server details (since uplink speed, RAM and CPU are relevant):



Measured Uplink speed is 2.03 Mbps (259 kb/s)

Measured Downlink speed is 19.41 Mbps (2'484 kb/s = 2.42 MB/s)

Server: Zotac Zbox, model forgotten ;)

RAM: 4GB

Processor: Intel(R) Atom(TM) CPU D510 (64 bit), dual core, 512 kb
cache



grep MemTotal /proc/meminfo

MemTotal:        4038512 kB





free -m

                    total       used       free     shared    buffers
  cached

Mem:          3943        469       3474          0         19
237

-/+ buffers/cache:        212       3731

Swap:         4087        179       3908







On Tue, Feb 18, 2014, at 06:49 AM, Greg Young wrote:

Did you by chance benchmark the fast cgi server for basic performance
numbers? Just curious how it sits compared to http listener.



Cheers,



Greg

On Tuesday, 18 February 2014, SirNoSkill <[5]quandary82 at hailmail.net>
wrote:

Hi,



I downloaded the sources for XSP from git.

And it seems Mono.WebServer.FastCgi has been under quite a bit of

change.

First I wanted to thank the person(s) responsible for it, seems like
the

fastcgi server is finally stable, or at least stable enough that it

hasn't crashed once in the last 2 weeks, including a performance load

test.

Keep up the good work.



One thing though:

It worked fine with TCP, but when I tried with unix sockets, I got this

error:

Error parsing permissions "". Use octal."



In file

/xsp/src/Mono.WebServer.FastCgi/main.cs

in function public static bool TryCreateUnixSocket (string path, out

Socket socket, string perm = null)



there is this code:

if (perm == null) {

    socket = new UnixSocket (realPath);

    Logger.Write (LogLevel.Debug, "Listening on file {0} with default

    permissions", realPath);

} else {

    ushort uperm;

    if (!UInt16.TryParse (perm, out uperm)) {

        Logger.Write (LogLevel.Error, "Error parsing permissions

        \"{0}\". Use octal.", perm);

        return false;

    }





that should probably be

if(string.IsNullOrEmpty(perm)){

because UInt16.TryParse will fail if perm is string.Empty.



If I fix this, fastcgi-server starts, but I get a HTTP 502.

Since the config works fine if I use TCP, I guess this is a

fastcgi-server bug.

Just thought I let you know.



It's unlikely it's a permission bug, since I let fastcgi-mono-server4

run as root.

Just in case, here my configuration settings:



This is my fastcgi-start script



#!/bin/sh



### BEGIN INIT INFO

# Provides:          monoserve.sh

# Required-Start:    $local_fs $syslog $remote_fs

# Required-Stop:     $local_fs $syslog $remote_fs

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Start fastcgi mono server with hosts

### END INIT INFO



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/bin/mono

NAME=monoserver

DESC=monoserver



MONOSERVER=$(which fastcgi-mono-server4)

MONOSERVER_PID=$(ps auxf | grep fastcgi-mono-server4.exe | grep -v grep

| awk '{print $2}')



WEBAPPS="[6]www.example.com:/:/root/VS2010/SqlWebAdmin/SqlWebAdmin/,exa
mple.com:/:/root/VS2010/SqlWebAdmin/SqlWebAdmin/"

#WEBAPPS="[7]www.domain1.xyz:/:/var/www/domain1.xyz/,www.domain2.xyz:/:
/var/www/domain2.xyz/"



case "$1" in

        start)

                if [ -z "${MONOSERVER_PID}" ]; then

                        echo "starting mono server"





                        # ${MONOSERVER} /applications=${WEBAPPS}

                        /socket=unix:/tmp/fastcgi.socket &

                        # ${MONOSERVER} /applications=${WEBAPPS}

                        /socket=tcp:[8]127.0.0.1:9000 &

                        ${MONOSERVER} /applications=${WEBAPPS}

                        /socket=unix:/var/run/mono3-fcgi.sock &

                        echo "mono server started"

                else

                        echo ${WEBAPPS}

                        echo "mono server is running"

                fi

        ;;

        stop)

                if [ -n "${MONOSERVER_PID}" ]; then

                        kill ${MONOSERVER_PID}

                        echo "mono server stopped"

                else

                        echo "mono server is not running"

                fi

        ;;

        *) echo "You have provided no or an invalid command line

        argument."

        ;;

esac



exit 0







and this the nginx configuration





##

# You should look at the following URL's in order to grasp a solid

understanding

# of Nginx configuration files in order to fully unleash the power of

Nginx.

# [9]http://wiki.nginx.org/Pitfalls

# [10]http://wiki.nginx.org/QuickStart

# [11]http://wiki.nginx.org/Configuration

#

# Generally, you will want to move this file somewhere, and start with
a

clean

# file but keep this around for reference. Or just disable in

sites-enabled.

#

# Please see /usr/share/doc/nginx-doc/examples/ for more detailed

examples.

##





 server {

         listen   80;

         server_name [12]www.example.com [13]example.com;

         access_log   /var/log/nginx/your.domain1.xyz.access.log;



         location / {

                 root /root/VS2010/SqlWebAdmin/SqlWebAdmin;

                 #index index.html index.htm default.aspx Default.aspx;

                 #fastcgi_index Default.aspx;

                 #fastcgi_pass [14]127.0.0.1:9000;

                 fastcgi_pass unix:/var/run/mono3-fcgi.sock;

                 include /etc/nginx/fastcgi_params;

         }









        location /doc {

                root /usr/share;

                autoindex on;

                allow 127.0.0.1;

                deny all;

        }



        location /shared_images {

                root /usr/share;

                autoindex off;

        }



        error_page 404 /CustomErrors/404.htm;



        # redirect server error pages to the static page /50x.html

        #

        #error_page 500 502 503 504 /50x.html;

        #location = /50x.html {

        #       root /usr/share/nginx/www;

        #}



}





/etc/hosts entries:

127.0.0.1       [15]example.com

127.0.0.1 [16]www.example.com





Kind regards



NoSkillz



--

[17]http://www.fastmail.fm - IMAP accessible web-mail



_______________________________________________

Mono-devel-list mailing list

Mono-devel-list at lists.ximian.com

[18]http://lists.ximian.com/mailman/listinfo/mono-devel-list







--

Le doute n'est pas une condition agréable, mais la certitude est
absurde.





--
SirNoSkill
[19]quandary82 at hailmail.net

References

1. https://loadimpact.com/load-test/www.daniel-steiger.ch-b67fbd0a9e513bdb6d1cfda8f044e082
2. http://88.84.21.77/
3. http://loadimpact.com/load-test/88.84.21.77-a7f4b192a3435b38405e2751299f8d05
4. http://loadimpact.com/load-test/daniel-steiger.ch-39452482e4a26c612d067e1582addb99
5. mailto:quandary82 at hailmail.net
6. http://www.example.com:/:/root/VS2010/SqlWebAdmin/SqlWebAdmin/,example.com:/:/root/VS2010/SqlWebAdmin/SqlWebAdmin/
7. http://www.domain1.xyz:/:/var/www/domain1.xyz/,www.domain2.xyz:/:/var/www/domain2.xyz/
8. http://127.0.0.1:9000/
9. http://wiki.nginx.org/Pitfalls
  10. http://wiki.nginx.org/QuickStart
  11. http://wiki.nginx.org/Configuration
  12. http://www.example.com/
  13. http://example.com/
  14. http://127.0.0.1:9000/
  15. http://example.com/
  16. http://www.example.com/
  17. http://www.fastmail.fm/
  18. http://lists.ximian.com/mailman/listinfo/mono-devel-list
  19. mailto:quandary82 at hailmail.net

-- 
http://www.fastmail.fm - A fast, anti-spam email service.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20140218/4c724fa3/attachment-0001.html>


More information about the Mono-devel-list mailing list