Code Monkey home page Code Monkey logo

Comments (3)

xplicit avatar xplicit commented on June 13, 2024

Can you post a reproducible test case?

from hyperfastcgi.

Ustimov avatar Ustimov commented on June 13, 2024
  1. All actions tested in clean Ubuntu 14.04.4.
  2. Download a database dump:
    wget https://www.dropbox.com/s/6tkw43o97ptoblk/forum.tar.gz?dl=0.
  3. Extract the dump:
    tar -xzf forum.tar.gz.
  4. Install MySQL:
    sudo apt-get install mysql-server mysql-client.
  5. Create a database and an user:
mysql -u root -p
create database forum;
create user 'admin'@'localhost' identified by 'admin';
grant all privileges on forum.* to 'admin'@'localhost';
exit
  1. Restore a database from the dump (long running operation, about 20-30 mins):
    mysql -u root -p forum < forum.sql
  2. Install mono, git and HyperFastCgi:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete
sudo apt-get install git
git clone https://github.com/xplicit/HyperFastCgi.githyperfastcgi4 `--config=server.config`
sudo apt-get install autoconf automake libtool make libglib2.0-dev libevent-dev
cd HyperFastCgi/
./autogen.sh --prefix=/usr
 make
 sudo make install
  1. Clone my project and build:
git clone https://github.com/Ustimov/Forums.git
cd Forums/
sudo apt-get install nuget
nuget restore
xbuild /p:Configuration=Release
  1. Install nginx:
    sudo apt-get install nginx
  2. Configure nginx and HyperFastCgi:
    create file
    sudo nano /etc/nginx/sites-available/forum
    and past (set paths according to your environment):
upstream fastcgi_backend {
  server 127.0.0.1:9000;
  keepalive 32;
}
server {
  listen 8000;
  server_name localhost:8000;
  error_log /var/log/nginx/Forum.Error.log;

  location / {
    root /root/Forums/Forum/;
    index index.html index.htm default.aspx Default.aspx;
    fastcgi_index Default.aspx;
    fastcgi_keep_conn on;
    fastcgi_pass fastcgi_backend;
    include /etc/nginx/fastcgi_params;
  }
}

create symlink to forum file

rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/forum /etc/nginx/sites-enabled/forum
sudo service nginx restart

create server.config with this content (set paths according to your environment):

<configuration>
        <server type="HyperFastCgi.ApplicationServers.SimpleApplicationServer">
                <!-- Host factory defines how host will be created. SystemWebHostFactory creates host in AppDomain in standard ASP.NET way --> 
                <host-factory>HyperFastCgi.HostFactories.SystemWebHostFactory</host-factory>
                <!-- <threads> creates threads at startup. Value "0" means default value --> 
                <threads min-worker="40" max-worker="0" min-io="4" max-io="0" />
                <!--- Sets the application host root directory -->
                <!-- <root-dir>/path/to/your/dir</root-dir> -->
        </server>
        <listener type="HyperFastCgi.Listeners.NativeListener">
                <apphost-transport type="HyperFastCgi.Transports.NativeTransport">
                        <multithreading>Single</multithreading>
                </apphost-transport>
            <protocol>InterNetwork</protocol>
            <address>127.0.0.1</address>
            <port>9000</port>
        </listener>
    <apphost type="HyperFastCgi.AppHosts.AspNet.AspNetApplicationHost">
                <log level="Debug" write-to-console="true" />
                <add-trailing-slash>false</add-trailing-slash>
    </apphost>
    <web-applications>
        <web-application>
                <name>Forum</name>
                <vhost>0.0.0.0</vhost>
                <vport>8000</vport>
                <vpath>/</vpath>
                <path>/root/Forums/Forum/</path>
        </web-application>
    </web-applications>
</configuration>


  1. Run application:
    hyperfastcgi4 --config=server.config
  2. Clone tests:
git clone https://github.com/s-stupnikov/technopark-db-api.git
cd technopark-db-api/tests/
nano perf_test.py 
change CONFIG_PATH = '/usr/local/etc/test.conf' to CONFIG_PATH = '../conf/test.conf'
  1. Download a test scenario:
    wget https://www.dropbox.com/s/eg5o1edz8y216j7/ustimov_httperf_scenario?dl=0.
  2. Install httperf and run tests:
sudo apt-get install httperf
httperf --hog --client=0/1 --server=127.0.0.1 --port=8000 --uri=/ --send-buffer=4096 --recv-buffer=16384 --add-header='Content-Type:application/json\n' --wsesslog=100,0.000,ustimov_httperf_scenario

P.S. With clean installation I doesn't get the same error (I use Debian before), but now I've get:

2016/06/04 14:00:25 [error] 1633#0: *77 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: localhost:8000, request: "GET /db/api/user/listPosts?limit=29&user=amizy%40ua.ru&order=asc HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
2016/06/04 14:00:25 [error] 1633#0: *79 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: localhost:8000, request: "GET /db/api/forum/listPosts?related=forum&related=thread&limit=25&order=asc&forum=1lnro HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

from hyperfastcgi.

xplicit avatar xplicit commented on June 13, 2024

"too big header" error message is unrelated to the error described in header of the issue and is expected behaviour of nginx.

Nginx has limitation of size for fast_cgi response headers, so if you want to send big headers in responses from your application you should increase these limits. There are settings fastcgi_buffer_size and fastcgi_buffers, for example.

             fastcgi_buffer_size 512k;
             fastcgi_buffers 512 4k;

The numbers in sample are pretty huge, so for real application you should tweak them to your needs. Here is an simple case how to tweak buffers: https://easyengine.io/tutorials/nginx/tweaking-fastcgi-buffers/

The second point that in your case you try to perform two mutually exclusive operations: profile the service and compute a performance. If you want to check performance of the service, you should disable MiniProfiler by commenting two lines here
https://github.com/Ustimov/Forums/blob/master/Forum/Global.asax.cs#L54
https://github.com/Ustimov/Forums/blob/master/Forum/Global.asax.cs#L59

because at every request mini profiler adds some info to the headers and after large number of requests headers become several megabytes in size. Measuring performance of few-bytes body content with megabyte headers does not make sense.

If you want to profile the service to see the bottlenecks then run limited number of requests and analyze data returned by ServiceStack.

If you meet "Sent unsupported FastCGI protocol version" again, please feel free and open new issue.

from hyperfastcgi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.