Gus
Gus

Reputation: 954

Jruby - rails app and sidekiq on same jvm instance

This a silly question, but couldn't find an answer. I'm running a rails app on jruby, and I use sidekiq to proccess background jobs. Do I really have to run sidekiq in another instance of jvm (is that what happens running bundle exec sidekiq) ?

Jruby is too much RAM consuming so this is not possible with my aws t2.micro instance.

Upvotes: 1

Views: 190

Answers (2)

RajaRaviVarma
RajaRaviVarma

Reputation: 2742

I know this is an old question, but for what it's worth (for people who come through Google):

You can try limiting the heap size used by JVM, reduce the number of Sidekiq workers, or try a job type that runs within the webserver process before giving other options a try.

Here is the link to JRuby Performance tuning: https://github.com/jruby/jruby/wiki/PerformanceTuning#java-virtual-machine-jvm-settings.

TLDR: Use the flag -J-Xmx<MEMORY_SIZE_IN_INTEGER>m to limit JVM's heap usage.

Passing a flag to JRuby

According to the wiki, you can configure a maximum heap size by invoking jruby with the flag -J-Xmx512m (512 MB of RAM). For example: jruby -J-Xmx512m server.rb.

Environment variable

JRuby flags can be configured in the JRUBY_OPTS environment variable. So, limiting the JVM heap size to 512 MB would mean setting `JRUBY_OPTS="-J-Xmx512m"

Upvotes: 0

Shiva
Shiva

Reputation: 12582

Due to high memory consumption your AWS microinstance will choke eventually. There is one way to have both Ruby App and Background process sidekiq running.

  • Either you can boot another EC2 micro with sidekiq. You app instance and sidekiq server will share the same Redis instance. So, your BG processing wont be disrupted.

  • Another way is to bootup a Heroku free dyno.

  • Or you can move to CRuby or MRI.

hope this helps

Upvotes: 0

Related Questions