Home > Net >  Use a different ruby with AWS ElasticBeanstalk
Use a different ruby with AWS ElasticBeanstalk

Time:12-26

I have an app that runs on Ruby 2.7.2. However, I detected a memory leak in Puma in cluster mode which doesn't go away with preload_app! and other configurations. I suspected the main culprit is ruby's memory management. The requests combines a huge JSON with nested arrays nested hashes etc.

So my idea was to use jemalloc ruby instead of the glibc malloc. Jemalloc reduces the problem in the local environment a little bit.

The current ruby AWS ELB keeps is in /opt/elasticbeanstalk/.rbenv/shims/ruby.

I want to use RVM instead, the ruby will be compiled with clang, with O3 optimization, march and mtune set to native, and use jemalloc instead:

CC=clang HOSTCC=clang CFLAGS="-O3 -march=native -mtune=native -fno-plt" rvm install 2.7-jemalloc --with-jemalloc

How do I set the ruby to RVM there in amazon linux used by ElasticBeanstalk?

CodePudding user response:

Probably the way to do this would be to prepare custom AMI for your EB. So you would take current Ruby-based EB, customize it to your needs, which includes changes to default version of the software, create an AMI of it, and then use your custom AMI instead of the default one provided by AWS.

  • Related