Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Component-Based Rails Applications - Ruby Uncon...

Component-Based Rails Applications - Ruby Unconf Hamburg 2019

Avatar for Gharbi Mohammed

Gharbi Mohammed

May 26, 2019

Other Decks in Programming

Transcript

  1. • Part 1 ◦ Monolithic obstacles ◦ Namespaces ◦ Introduction

    to Engines ◦ Split the app into portions • Part 2 ◦ Speed up deployment ◦ Decrease memory usage ◦ Deploy to separate servers Content
  2. What is a Rails engine? A mini Rails application that

    can be mountable inside your main Rails application.
  3. Benefits • Component based architecture is complementary to good object

    oriented practices • Engines use namespaces • It enforces an internal dependency structure • Cleaner Gemfile • Cleaner routes.rb • Fast tests • Team collaboration
  4. Speed up deployment $ bundle --without api public Gems in

    the group api and public were not installed.
  5. Public UI Admin UI $ RUNNING_MODE=public rails s $ RUNNING_MODE=admin

    rails s http://my-cbra-app.com http://my-cbra-app-super-secret-domain.com/admin
  6. memory_usage = `ps -o rss= -p #{Process.pid}`.to_i render text: "Ruby

    process memory usage #{memory_usage} KB" Benchmarking a practical example localhost:3000/benchmark
  7. Running admin only: Ruby process memory usage 256548 KB Running

    everything api, public, dashboard and admin: Ruby process memory usage 356032 KB Benchmarking a practical example