wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname
=> ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com
Some of the solution I found develping software using Ruby, Rails, Sinatra, and MongoDB!
mardi 8 octobre 2013
Sidekiq is not faster than Resque
I changed my background job from Resque to Sidekiq, but i was suprise that, it was not currently faster anymore.
I found a possible problem: databse access: my jobs where accessing database.
i have 20 sidekiq worker.
I put a pool_size for the database of 22 (1 web worker, 1 rake console, 20 workers .. in my yml) and also 22 database connections in mongD. It solved the problem. What takes before 1 hours take less than afterwards 10 minutes.
mongo.yml:
staging:
adapter: mongodb
database: database_name
host: localhost
port: 27017
options:
pool_size: 22
$ cat /etc/mongodb.conf |grep max
maxConns=1000
It may not be the more efficient settings, but I didn't have enougt time to tune them!
Requirement problems for Sidekiq
I wanted to use Sidekiq instead of Resque to handle my background jobs.
After normal changes I had lots of this kind of errors:
NoMethodError: undefined method `find' for #<User:0x00000003c8ea08>
NameError: uninitialized constant User
It was a requirement problem. I required everything with autoload, which is not thread-safe. - and deprecated-. I've changed for require.
Instead of
autoload :User, 'model/useer'
i use
require root_path + '/app/models/User.rb'
And no more error :)
After normal changes I had lots of this kind of errors:
NoMethodError: undefined method `find' for #<User:0x00000003c8ea08>
NameError: uninitialized constant User
It was a requirement problem. I required everything with autoload, which is not thread-safe. - and deprecated-. I've changed for require.
Instead of
autoload :User, 'model/useer'
i use
require root_path + '/app/models/User.rb'
And no more error :)
Inscription à :
Articles (Atom)