Posted by stoyan
After reading Rails Plugin: Throttler I created a Throttler Ramaze Helper .
- What is it for? ”...The throttling plugin monitors the load of your server and allows you to disable certain features of your app when the load is too high…”
- How to use it?
Thanks a lot to Kashia from #ramaze for the help.
Later I start thinking “Hm, maybe that one is better to be Rack middleware ...”. Maybe next try…
Posted by stoyan
Problem (after any package install i’ve got):
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Solution:
$ sudo apt-get install language-pack-en
Posted by stoyan
via DebianHelp
...Disabling the TCP options reduces the overhead of each TCP packet and might help to get the last few percent of performance out of the server. Be aware that disabling these options most likely decreases performance for high-latency and lossy links.
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
Increasing the TCP send and receive buffers will increase the performance a lot if (and only if) you have a lot of large files to send.
net.ipv4.tcp_wmem = 4096 65536 524288
net.core.wmem_max = 1048576
If you have a lot of large file uploads, increasing the receive buffers will help.
net.ipv4.tcp_rmem = 4096 87380 524288
net.core.rmem_max = 1048576
Posted by stoyan
The new server upgrade system.
1. Install update-manager-core:
$ sudo apt-get install update-manager-core
2. Launch the upgrade tool:
$ sudo do-release-upgrade
Like usual, there is no step 3 ;)
Posted by stoyan
Origin: discussion on comp.lang.ruby
...It appears that when compiled with —enable-pthread ruby will call sigprocmask MANY MANY more times than without. You can verify this with strace -c:
$ strace -c ruby -e '1.upto(100000) {|i| i.to_s}'
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
99.65 1.462627 7 200006 sigprocmask
Solution:
Update 2007/12/13: Replace the default ruby install on Ubuntu
$ sudo apt-get install ruby irb ri rdoc ruby1.8-dev
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
$ tar xvzf ruby-1.8.6-p110.tar.gz && cd ruby-1.8.6-p110
$ sudo apt-get build-dep ruby1.8
$ ./configure --prefix=/usr
$ make
$ sudo make install
$ ruby -v
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-linux]
Posted by stoyan
Preparation
I added PHP to bbox512 nginx . For Debian/Ubuntu it needed FastCGI:
# apt-get install libfcgi0
RTFM
Installation
# cd /etc/default/
# wget -O php-fastcgi http://zhware.net/files/nginx/php-fastcgi.txt
# cd /etc/init.d/
# wget -O php-fastcgi http://zhware.net/files/nginx/php-fastcgi.rc.txt
# chmod 755 php-fastcgi
# cd /opt/nginx/conf/sites/
# wget -O static.conf http://zhware.net/files/nginx/sites/static.conf.txt
# /etc/init.d/php-fastcgi start
# kill -HUP `cat /opt/nginx/logs/nginx.pid`
In fact it’s just starting FastCGI PHP instances and making small changes to the sites/static.conf to process files with .php extension:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}
Posted by stoyan
On
bbox2 i installed
swiftiply gem . This changed the
mongrel_rails command to use evented mongrel – mongrel, patched to use
eventmachine tcp stack instead of the original pure ruby one.
In
/etc/init.d/mongrel_cluster i’m starting all mongrel instances with:
env EVENT=1 mongrel_cluster_ctl start ...
And because only testing is boring ;) I deployed
restolog also to
bbox2 . Now it’s available on both
bbox and
bbox2:
So now there is a “real world” application running on nginx+evented mongrel cluster. In fact the current post is done via bbox2 :)
The backend is the same database, so there will be no duplicated etc. posts.
I wanted to do the benchmarks again but ab seems buggy – it’s hang after sending 900 requests ( -c 100 -n 1000 ). Searching the internet gave me that: ab hang .
Hm, maybe will try httperf.
Posted by stoyan
I installed JuneBug wiki on bbox . There was some bugs in the installation documentation so will put small notes here. The installation process is for Ubuntu Dapper box on BrightBox beta hosting. Adjust for your own situation:
# Ubuntu/Debian specific
apt-get install sqlite3 libsqlite3-dev
# the original document missing http://
# in front of the url
# ERROR: uri is not an HTTP URI
gem install sqlite3-ruby --source http://code.whytheluckystiff.net
gem install junebug-wiki -y
Question: Is it still needed to install custom sqlite3 version or the stock one from the gems repository will do the job?
Posted by stoyan
There is a new version of the nginx web server – nginx-0.5.24 . Too many upgrades recently :(
From the changelog:
Bugfix: a part of response body may be passed uncompressed if gzip was used; bug appeared in 0.5.23.
I have a small ugly shell script for upgrading:
#!/bin/sh
VER=0.5.24
if [ ! -d ~/Work/nginx-${VER} ]; then
cd ~/Work
wget http://sysoev.ru/nginx/nginx-${VER}.tar.gz && \
tar xvzf nginx-${VER}.tar.gz
fi
if [ -d ~/Work/nginx-${VER} ]; then
cd ~/Work/nginx-${VER} && ./configure --prefix=/opt/nginx \
--with-openssl=/usr/lib/ --with-sha1=/usr/lib \
--with-http_realip_module --with-http_ssl_module && make
fi
The interesting part is after the installation –
upgrade the server executable “on the fly” , without restarting:
% cd ~/Work/nginx-0.5.24
% sudo make install
% sudo kill -USR2 `cat /opt/nginx/logs/nginx.pid`
% tail -f /opt/nginx/logs/error.log
2007/06/07 14:27:23 [notice] 4382#0: signal 12 (SIGUSR2) received, changing binary
2007/06/07 14:27:23 [notice] 4382#0: changing binary
2007/06/07 14:27:23 [notice] 4382#0: start new binary process 6500
2007/06/07 14:27:23 [notice] 6500#0: using inherited sockets from "6;7;"
2007/06/07 14:27:23 [notice] 6500#0: using the "epoll" event method
2007/06/07 14:27:23 [notice] 6500#0: nginx/0.5.24
Well done software = happy sysadmin = happy users :)
Posted by stoyan
via Jean-Francois Stenuit’s post to the Pound ML:
...If you run your pound in a chroot jail under linux and have error messages of the like :
Feb 28 09:37:57 revproxy07 pound: gethostbyname(...): Unknown host
Just check the settings of your jail :
# ls -l /var/run/chroot/pound/lib
total 56
-rw-r--r-- 1 root root 35288 Apr 19 14:05 libgcc_s.so.1
-rwxr-xr-x 1 root root 18316 Apr 19 14:05 libnss_dns-2.5.so
lrwxrwxrwx 1 root root 22 Apr 19 14:05 libnss_dns.so.2 -> /lib/libnss_dns-2.5.so
Those are the two libraries you need in your jail for pound to play with…
Posted by stoyan
origin: gabito.com blog post
...I’ve finally gotten my 500 error rate down to 0 by making some minor changes to the signal handling code of dispatch.fcgi. If the dispatch.fcgi process is in the midst of handling a request I defer letting it be killed until the request is complete. I did this by installing a custom TERM signal handler that protects the dispatch.fcgi process while a request is being processed…
Posted by stoyan
I put some notes for nginx on my wiki .
The rails system administration is like waves – somebody found a new software and the community just fulfill it. Maybe there must be some name for this effect. Something like digg-effect but maybe Rails wave hahaha.
First there was lighttpd , now nginx comming. Maybe your piece of code will be the next. Are your ready? ;)
Posted by stoyan
Great news from LiteSpeed Technologies – after a post to the forum they have “X-Forwarded-Proto: https” AUTOMATICALY added to the headers, when proxing requests, initially comming via HTTPS. Now Rails applications are not confused, when doing redirects for HTTPS. Good to be added to Litespeed+Mongrel docs .
The litespeed-2.1.17 is already available for download (even still there is no announce).
Posted by stoyan
mongrel_cluster makes it easy to manage multiple Mongrel processes behind a reverse-proxy server and load balancer such as Pound, Balance, Lighttpd, or Apache.
See also:
Posted by stoyan
Found very good site: steve.org.uk
Some interesting stuff:
- Argo — Xen Monitor / Control Panel. Simple, extensible, framework for controling a host running multiple Xen instances. Exactly what I need for the company.
- lua-httpd — simple, but pretty good Lua http server. Even have support for vhosts!
- Fortress — a simple script-based security scanner. C++ code, but tests should be written in Lua.
Steve Kemp have also very interesting weblog .