Tuesday, January 22, 2013

RaspberryPi como servidor web

Cherokee


Hacer la instalación de Cherokee Web Server en el Raspberry Pi con Raspbian es fácil, pero requiere tiempo.

wget http://cherokee-project.com/install && sudo python install
 

Y hay que esperar que la compilación se termina (mas de 30 min., me parece), con éxito (esperamos).

Dinámico

 

El Pi es pequeño en cuanto a su tamaño, pero también en cuanto a la cantidad de RAM y de core en el CPU. En cuanto a un sitio de tipo dinámico, es posible hacerlo con un Pi, pero hay que pensar en la aplicación. Como servidor personal o de departamento, es bueno.

Pero, y un blog? En mi caso, he notado que a veces hay 75+ visitantes al mismo tiempo. No es razonable esperar que un Pi puede hacerlo de manera dinámica. Por eso, vamos a ver lo que podemos esperar con Cherokee y un contenido estático.

Estático


Primero, voy a iniciar Cherokee:

$ sudo /opt/cherokee/sbin/cherokee -d

Luego voy a configurar el modo automático, pero por ahora es suficiente así.

Debemos poner una pagina como test:

$ cd /opt/cherokee/var/www
$ sudo wget http://raspberry-python.blogspot.com/2013/01/going-in-wrong-direction.html

En mi workstation, tengo apache, con ab:

$ which ab
/usr/bin/ab
$ ab
ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make
    -t timelimit    Seconds to max. wait for responses
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header for POSTing, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)


Ahora, podemos hacer una simulación de carga.

Vamos a hacer 1000 solicitudes en total (-n), y 75 al mismo tiempo (-c):

$ ab -n 1000 -c 75 -v 1 http://raspberrypi/going-in-wrong-direction.html
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 raspberrypi (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Cherokee/1.2.101
Server Hostname:        raspberrypi
Server Port:            80

Document Path:          /going-in-wrong-direction.html
Document Length:        208790 bytes

Concurrency Level:      75
Time taken for tests:   18.010 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      209724452 bytes
HTML transferred:       209520640 bytes
Requests per second:    55.53 [#/sec] (mean)
Time per request:       1350.741 [ms] (mean)
Time per request:       18.010 [ms] (mean, across all concurrent requests)
Transfer rate:          11372.03 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   96  36.0    109     128
Processing:   132 1232 266.1   1166    2738
Waiting:       16  182 153.4    126     949
Total:        143 1328 262.7   1278    2853

Percentage of the requests served within a certain time (ms)
  50%   1278
  66%   1320
  75%   1417
  80%   1479
  90%   1671
  95%   1777
  98%   1951
  99%   2060
 100%   2853 (longest request)

Aprobado


Así que, me parece que con contenido estático (quizás generado por medio de Pelican), y con poco imágenes (en el test aquí, ninguna), si, el Raspberry Pi podría servir de servidor de blog.

@f_dion

1 comment:

Unknown said...

In spite, the particular view confident myself which usually that is the brand spanking new range in which enjoy is, as well as a lot more durable confusing movement and fabulous display, this particular clock is not perhaps the actual legend of this gallery however, which is additionally an account for the purpose of yet another piece of writing. I truly do not need this to help with making this specific section in no way noise essential, mainly because in several ways it does not take vital latest view possesses presented. Is not sole quite gorgeous, although a symbol about when this manufacturer is actually on course covering the up coming three years a new enhanced glimpse which usually enhancements the general truly feel involving timepieces which has an focus on further obtainable haute horology. Easily sanctioned focus on just what exactly essentials to add right follow to make sure you complement it for featuring its ways of life in the form of authoring the windshield wonder maker http://www.replicabestsale.co.uk. Any watch would be the title within the company well-known and additionally old arranged. Remember that it is put on running watches previous to, but the range is a completely new family of different watches along with a seem which usually. Good a new start looking of which honestly is visually nearly the same as a wristwatch. These days absolutely nothing in the least completely wrong repair, and even now is the time granted story.