Friday, January 04, 2008

[Mongrel ESI] Ragel Parser, and more!


I've been busy this new years. I was bitten by a bug to improve mongrel esi. First, I set down to finally master ragel. I initially, implemented the ragel parser using ruby. Then after some performance tests discovered while it had improved the performance stability it had actually reduced the average performance. It really wasn't too difficult, once I had the parser written and working in ruby to convert it into C, which today I can finally say is complete and all tests are again passing. With the new C ragel implementation I am seeing about a 2x improvement in raw performance. My methods for measuring performance have been largely based on ab (apache benchmark).


Today I spent time to really understand how mongrel_rails works and in doing so was able to rework the servers configuration so that it can take a simple ruby script or yaml file, but all configuration options are by default passed via the command line. Here's how the configuration works now:



ESI::Config.define(listeners) do|config|

# define the caching rules globally for all routes, defaults to ruby
config.cache do|c|
#c.memcached do|mc|
# mc.servers = ['localhost:11211']
# mc.debug = false
# mc.namespace = 'mesi'
# mc.readonly = false
#end
c.ttl = 600
end

# define rules for when to enable esi processing globally for all routes
config.esi do|c|
c.allowed_content_types = ['text/plain', 'text/html']
#c.enable_for_surrogate_only = true # default is false
end

# define request path routing rules
config.routes do|s|
#s.match( /content/ ) do|r|
# r.servers = ['127.0.0.1:4000']
#end
s.default do|r|
r.servers = ['127.0.0.1:3000']
end
end

end


I've been posting new gems to http://mongrel-esi.googlecode.com/files/mongrel_esi-0.4.0.gem

0 comments:

Reading list