0
0
Ruby on Railsframework~15 mins

Puma server configuration in Ruby on Rails - Mini Project: Build & Apply

Choose your learning style9 modes available
Puma Server Configuration
📖 Scenario: You are setting up a Ruby on Rails application to run with the Puma web server. Puma needs a configuration file to define how it handles threads, workers, and ports.
🎯 Goal: Create a config/puma.rb file that sets up Puma with a thread pool, worker count, and port number for your Rails app.
📋 What You'll Learn
Create a thread pool size range with minimum 5 and maximum 5 threads
Set the port to 3000
Set the number of workers to 2
Add a preload_app! directive to optimize memory usage
💡 Why This Matters
🌍 Real World
Puma is a popular web server for Ruby on Rails apps. Configuring it properly ensures your app runs efficiently and handles multiple requests smoothly.
💼 Career
Knowing how to configure Puma is essential for Rails developers working on production-ready applications and deploying to servers.
Progress0 / 4 steps
1
Create thread pool size range
Create a variable called threads_count and set it to 5. Then use threads threads_count, threads_count to configure Puma's thread pool size.
Ruby on Rails
Need a hint?

Use the threads method with two arguments for minimum and maximum threads.

2
Set the port number
Add a line to set the Puma server port to 3000 using port 3000.
Ruby on Rails
Need a hint?

Use the port method with the port number as argument.

3
Set the number of workers
Add a line to set the number of Puma workers to 2 using workers 2.
Ruby on Rails
Need a hint?

Use the workers method to specify the number of worker processes.

4
Add preload_app! directive
Add a line with preload_app! to enable application preloading for better memory usage.
Ruby on Rails
Need a hint?

This directive tells Puma to load the app before workers fork.