Jun 252010

You can monitor your servers nicely graphs using iStat for iphone.
these are instructions for Gentoo:reteks.ru

Create and edit /etc/istat.conf to match your server specs.
This config is for my OpenVZ vps.

Start istatd server:

you might add it to /etc/conf.d/local.start to auload on startup

Then download iStat for iphone http://bjango .com/apps/istat/ it’s only $0.99
and add your server to the list.

Here are some screenshots, first is server and second image is my macbook discovered with bonjour.

#gallery-1 {
margin: auto;
#gallery-1 .gallery-item {
float: left;
margin-top: 10px;
text-align: center;
width: 33%;
#gallery-1 img {
border: 2px solid #cfcfcf;
#gallery-1 .gallery-caption {
margin-left: 0;
/* see gallery_shortcode() in wp-includes/media.php */

Jun 142009

I have came across many projects where checking file uploads and content-type (mime-type) is poorly implemented or heavy in resource.http://mediamusique.com/

Methods I have seen so far:link

1. Checking content-type from file name: this inefficient, a user can just rename a file and you are fooled, or the file can have a different file format and you will not get the expected result.

2. Using Rmagick to check if the file is an image. This is so slow and uses so much Ram. You can try to initialize an rmagick object from an image file, then rescue when the file is not an image.

3. Using mini_magick to check if a file. This method is faster than rmagick. Implemen ted same way as rmagick.

A Better method for OSX and Linux,  is to use the command line tool “file” included in most UNIX operating systems.

It is very fast and very accurate.

Some examples of content types:

.doc = Microsoft Word document data

.doc = Microsoft Office Document

.pdf = PDF document, version 1.4

.pdf = PDF document, version 1.3

.psd = Adobe Photoshop Image

.png = PNG image data, 3508 x 4961, 8-bit/color RGBA, non-interlaced

.gif = GIF image data, version 89a, 195 x 109

.jpg = JPEG image data, EXIF standard


I hope this can be useful to someone.

Jan 252009

Have you edited or tweaked your pipeline settings in Firefox?http://rpk-tramplin.ru

You can do it by typing about:config in your firefox url tab.

Most blogs and tutorial will tell you to set high values to improve the speed, such as this one: www.mydigitallife.info/2007/10/16/speed-up-your-firefox-by-adjusting-your-http-pipelining/

Many people will go crazy and make values even higher such as:

network.http.pipelining.maxrequests 32
network.http.max-persistent-connections-per-proxy 128
network.http.max-persistent-connections-per-server 128
network.http.max-connections-per-server 256

These settings are very high and will create at least 32 connections to your server.

if you have many images and SSI includes, it could overload your apache webserver.
If you use apache2.2 with worker_mpm it will create 1 thread for each connection, thus you will have 32 new threads forked within just a few seconds.

Of course if you have a quad-core server with lots of ram you should not bother to read this.
But for most cheap vps and single core servers, it can really help.

so how you do it? simple, just use iptables conn_limit module

you may need to adjust the order or to insert or append like

# to apped to the end of the INPUT chain:
iptables -A input …
# to insert at position 10 of the input chain:
iptables -I input 10 …

I have tested this schema and work very well with firefox pipeline freaks.

the server will only then take up to 8 simultaneously connections per IP

to test the established connections you can try with netstat from the server:

Any comments, suggestions are welcome …


This can be not so good to legit users behind a proxy or firewall, because the the IP will be unique to all users behind the proxy/firewall.

in this case, you would increase the limit value.

Easy installing Passenger mod_rails on gentoo Linux

 gentoo, linux  Comments Off on Easy installing Passenger mod_rails on gentoo Linux
Aug 062008

To install the great Mod_Rails on Gentoo linux it’s as easy as 5 steps.aton-mebel.ru

Since you are Gentoo user, i don’t need to go to details. You know what you doing. ;)

Update: Mod-rails now works with apache mpm-worker

add this to /etc/portage/package.use

and this to /etc/make.conf

If it tries to install rails 2.2.2, rake, and lots of other gems that you already have installed trough rubygems, then run emerge with –nodeps option

for example mine looks like this:

That’s it.

Now just drop a similar vhost config file inside /etc/apache/vhosts.d/

This is a sample vhost file for a rails app.

My sample deflate.conf,
used to gzip the content

* Update on July 10, 2008.

– Now using gentoo portage to install it. it’s more smooth.


Personally I found that Thin + nginx uses less memory(Nginx 4MB + each thin server) than
apache + passenger, which uses quite more. (Apache: 50MB + each rails spawner)

Very low memory VPS Linux for Rails

 linux, vps  Comments Off on Very low memory VPS Linux for Rails
Jul 032008

The other day I had to set up a VPS machine at Slicehost for a client on a tight budget. I paid for 256mb VPS based on Gentoo, my distro of choice.vian34.ru

But 256MB of ram? what can you do with just 256?

Normally a default 256mb linux machine would not handle very well a set of Apache + Mysql + 1 mongrel/thin/ebb instance. due to the high memory usage of a default configuration, it will swap very often.

After much research and instinct i made it run one thin servers with mysql and nginx, without any swapping, and really fast as it can be.

If your linux start swapping often your performance will go down to the floor… Swapping is bad, specially on a XEN VPS.

The trick is to setup Mysql to use MYISAM and use Nginx instead of apache.

Here is the process list with the Resident Memory usage, after 30 days uptime and about 1,800 page views on the website.

and others, such as sshd, cron, iptables, bash, together about 5mb.

As you can see, total of memory usage of the applications on the server is about 83 MB, thus leaving the server with 170MB of ram for the linux itself and file cache.

this is what #free command tells:

Nice uh?
you can also make use of the nice tool called “vmstat”
it’s very import that ‘si’ (swap in) and ‘so’ (swap out) stays zero all the time.

i.e. running vmstat 10 times with a 4 seconds interval. (ignore the 1st line)

You can read about it more in here:


I forgot to add that you need to dump your database first:

mysqldump -u root –all-databases > dump.sql

then change my.cnf accordingly,

restart mysql and reload the database

mysql -u root < dump.sql

Change only the values for my.cnf as shown below, and delete all innodb related stuff

If you get problems reloading the database, stop mysql delete the contents in /var/lib/mysql/* , then run mysql-installdb and start it and reload again the sql dump file.

Actually that’s the way i most prefer..

this is an example nginx config file, located at /etc/nginx/nginx.conf

this is an example vhost file

Some linux distros have enabled by default services we dont need.

such as cupsd, apmd, acpid, mdns, samba, nfs, ftpd… etc…

Note that I set MAKEOPTS=”-J1″ , it will only use 1 gcc process at the time, and not disturb the system, (machine has 4 cores)

Also portage_niceness to 18, to make sure it will run smooth and not disturb thin and mysql.

from nice man page: “Nicenesses range from -20 (most favorable scheduling) to 19 (least favorable).”

if you want to use mod_rails Passenger, set APACHE2_MPMS=’prefork’

note: I am positive you can throw in another thin server instance, and it will still not swap, or swap very little at all.

have fun


Wanna know what Slicehost Manager Diagnostics says about my VPS ?

Switch to our mobile site