Install ruby memcached on MacOSX 2 comments
Classical way, download following archives and compile it in the order. Xcode has to be installed.
tar xzf *.tar.gz
cd
./configure
make
sudo make installScrubyt on Rails 2 comments
If like me you have an error after installing scrubyt 0.3.4 (in console and launching mongrel):
can't activate RubyInline (= 3.6.3), already activated RubyInline-3.6.4]I spent a lot of time to find the solution, and so easy solution … anyway could be useful for people googling about this. You just need to unsinstall the lastest installed version of RubyInline:
sudo gem uninstall RubyInline -v 3.6.4Everything should be fine with this, even Scrubyt requiring version 3.6.3.
Scaling a Rails app (Part 2 of 3) no comments
This the second part for a summary about solutions to help better computing of your rails app (1st part).
Application
To help your application to focus on replying fast to user, you can use a distributed queueing to give the job to other processes:
And second thing, you can cache things you don’t need to compute for each request, this can incredibly increase the response of your server, but need to modify your code and it s recommend for very big sites:
Back end
DB
For your database you can find some sql proxy, but I haven’t tried it yet. You have also the way to replicate your databse and serve data from several servers.
- sql relay
- use jruby with a jdbc pool connection and caching
Important things you have to check about your databse is if you have the right indexed fields. You should find some tools on mysql helping you to find where indexes missing. Check about cache too.
A last way is to serialize some of your data in a single object.
Mysql
Otherwise you can configure your mysql with some optimized configuration (mysql.ini):
- skip-name-resolve
- query_cache_size = 52428800;
- query_cache_type = 1
And in your ActiveRecord object you can use the * parameter.
Filesystem
Optimizing the filesystem, in other sense than choose a good OS, can been done with not overloading the management of files by using some *rules:
- max 10K files / subdir
- 16 top level / 256 sub / 10K per sub dir
- use a hasher to manage files
OS
As we have seen, file and memory management are keys of good performances. And these are managed by OS. The two best OSs mentionned are
- Sunsolaris
- FreeBSD (can be use for a all in one stack), avoid the version 5
And upcoming, last part of this article, some home made benchmarks for my own purpose.
Scaling a Rails app (Part 1 of 3) no comments
One of the most interesting topic in the RailsConf was Scaling your Rails app. There are 2 ways of doing it:
- adapt your code
- adapt your servers
But the second one will not help to make your code faster. It will just help to give maximum resources to compute it right.
Summaries from the conference (sorry for the so few litterature it will be only a summarize):
Some theories
These theories are for big websites with millions of hits every month. This can involve thousand of servers, different location, ... BTW some tips can be use to help smaller configurations.
The 7 layers to be considered, a la OSI.
- DNS
- frontend
- proxy
- application server
- application
- backend (Db , filesystem)
- OS
DNS
Nice website to check your DNS configuration: dnsstuff.com Good tool to optimize your DNS: speed, dispatching, and so on…: powerdns
DNS can be quite fast to address the right server from a request, scripts allow to manage complex configurations. The tip is to use 1 DNS entry per 1 controller, then managing part of the routing.
Frontend and Proxy
Load balancing is about dispatching requests taking in account the charge of each cluster.
Load balancers: Varnish HAProxy
Both look promising and HAProxy seems to be more and more popular.
Front end with load balancer: Nginx : fast, low memory usage, http server with load balancing, easy configuration, very good in front of mongrel cluster. Apache 2.2 + mod_proxy_balancer, you can find how to setup it in previous post: apapche, mongrel cluster, rails on a load balancer
Application server
- mongrel server: enough for a personnal server gem install mongrel mongrel_rails start (more information)
- mongrel_cluster: useful to scale up your configuration, need at least a multi-processor or multi server environnment. gem install mongrel_cluster mongrel_rails cluster::configure … mongrel_rails cluster::start
- Evented Mongrel (swiftiply): it’s a mongrel based an event triggering
- jruby / glassfish: the technology java comes with some good environment to speed up part of your application like connection to database (jdbc, pool connection)
to be continued (application, backend, OS, and some home benchmark)




