ROR: Puma webserver doesn't process multiple request at a time - ruby-on-rails

I'm using rails5.2. For testing i've created below controller.
class IndexController < ApplicationController
def index
sleep(10)
render text: "done"
end
end
If I make 5 parallel requests, 1st request takes 10s, 2nd takes 20s, 3rd takes 30s and so on..
myAppRails5 aravind$ bin/rails server
=> Booting Puma
=> Rails 5.2.0 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.11.4 (ruby 2.5.1-p57), codename: Love Song
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Puma configuration : Min threads: 5, max threads: 5
Rails 5.2.0 application starting in development
development.rb
puma.rb
As per puma doc, threaded is supported. How do I achieve multi threading here?

Related

Puma-dev and Rails s both run same version of puma but produce different results

Trying to debug a confusing issue. Upgrading an old app from Rails 3.22.xx -> 4.2.11.3.
If I run rails s the server boots up and the app loads just fine.
=> Booting Puma
=> Rails 4.2.11.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[20409] Puma starting in cluster mode...
[20409] * Puma version: 5.5.2 (ruby 2.4.0-p0) ("Zawgyi")
[20409] * Min threads: 8
[20409] * Max threads: 32
[20409] * Environment: development
[20409] * Master PID: 20409
[20409] * Workers: 2
[20409] * Restarts: (✔) hot (✖) phased
[20409] * Preloading application
[20409] * Listening on http://127.0.0.1:3000
[20409] * Listening on http://[::1]:3000
[20409] Use Ctrl-C to stop
If I use the domain set for puma-dev however, it errors out. The error is related to mongo gem and BSON serialization.
In the below code value is just something I am logging out from the mongo gem.
appName[28214]: bash: no job control in this shell
appName[28214]: Puma starting in single mode...
appName[28214]: * Puma version: 5.5.2 (ruby 2.4.0-p0) ("Zawgyi")
appName[28214]: * Min threads: 0
appName[28214]: * Max threads: 5
appName[28214]: * Environment: development
appName[28214]: * PID: 28214
appName[28214]: VALUE : {:ping=>1}
appName[28214]: VALUE :
appName[28214]: VALUE : {:ping=>1, "$db"=>"admin"}
appName[28214]: VALUE : {:ismaster=>1}
appName[28214]: VALUE :
appName[28214]: VALUE : {:ismaster=>1, "$db"=>"admin"}
appName[28214]: * Listening on unix:/Users/rockwellrice/.puma-dev/appName/tmp/puma-dev-431.sock
appName[28214]: Use Ctrl-C to stop
! App 'appName' booted
appName[28214]: VALUE : {:ismaster=>1, :compression=>[], :client=>{"driver"=>{"name"=>"mongo-ruby-driver", "version"=>"2.7.0"}, "os"=>{"type"=>"darwin", "name"=>"darwin18.7.0", "architecture"=>"x86_64"}, "platform"=>"mongoid-5.4.1, 2.4.0, x86_64-darwin18, x86_64-apple-darwin18.7.0"}}
appName[28214]: VALUE :
appName[28214]: VALUE : {"find"=>"users", "filter"=>{"_id"=>"93221de412af253e53231735"}, "limit"=>1, "singleBatch"=>true, "$db"=>"reader", "lsid"=>{"id"=><BSON::Binary:0x70235818644900 type=uuid data=0x4730a5f638de4dce...>}}
The error specifically happens when it grabs the user ID value and it returns
BSON::Error::UnserializableClass
Value does not define its BSON serialized type: 93221de412af253e53231735
I am confused why this happens when loading through puma dev but not when using Rails s and going to localhost:3000.
Ruby on rails 4.2.11.3, Mongo 2.7.0, MongoID 5.4.1.

Rails 6 are you trying to open an SSL connection to a non-SSL Puma?

I'm trying to set up Rails on AWS ECS with HTTPS access. When my ECS Service is deployed, these are the logs:
=> Rails 6.1.3.2 application starting in production
=> Booting Puma
* Listening on http://0.0.0.0:3000
* PID: 1
* Environment: production
* Max threads: 5
* Min threads: 5
* Puma version: 5.3.2 (ruby 3.0.1-p64) ("Sweetnighter")
Puma starting in single mode...
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
2021-08-06 06:21:21 +0000 HTTP parse error, malformed request:
#<Puma::HttpParserError: Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?>
I believe the health checks are hitting the container and failing. I'm not sure why this is happening. I already set config.force_ssl = true in my environments/production.rb. Any suggestions on what I am missing?
I'm using Rails 6.1.3.2 and ruby 3.0.1. Thanks!

Rails Server working in command line. Not at Localhost

rails server
=> Booting Puma
=> Rails 5.2.0 application starting in development
=> Run rails server -h for more startup options
[44266] Puma starting in cluster mode...
[44266] * Version 3.6.2 (ruby 2.5.1-p57), codename: Sleepy Sunday Serenity
[44266] * Min threads: 5, max threads: 5
[44266] * Environment: development
[44266] * Process workers: 1
[44266] * Preloading application
[44266] * Listening on tcp://localhost:3000
[44266] Use Ctrl-C to stop
[44266] - Worker 0 (pid: 44286) booted, phase: 0
^C[44266] - Gracefully shutting down workers...
[44266] === puma shutdown: 2018-06-12 14:28:53 -0500 ===
[44266] - Goodbye!
Exiting
went to http://www.localhost3000.org/
says you forgot to start your server
Running
Rails 5.2.0
Postgesql 9.6
It looks like http://www.localhost3000.org/ is a website that someone bought to help you when you mistype your attempt to get to your localhost. It's not your own server responding
As the website suggests, try to go instead to http://localhost:3000
Use this address localhost:3000. The link you included is a live website someone has published as a reminder to start your server.
Use this address http://localhost:3000 but you can still edit your url, follow this article: Edit localhost

Puma rails server not starting in Daemon mode on EC-2

I want to run Rails application on EC2 machine. When my SSH session terminates the rails server shutdown. I want to run the rails server in the background. I used rails s -d command to run rails daemon mode.
But it seems like Puma is not started. This is the message I receive and after that process terminates.
Booting Puma
=> Rails 5.0.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Usually when I run rails server I get
=> Booting Puma
=> Rails 5.0.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.11.0 (ruby 2.3.5-p376), codename: Love Song
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
What is going wrong? Is puma server booting up but not starting?

Why is rails server listing on tcp

I am working on a project which is an updated version of a new project. Using vagrant to load virtual environment and when i run
RAILS_ENV=development bundle exec rails s
The following is returned:
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
When i visit the browser I have tried localhost:3000 and 127.0.0.1:3000 but keep getting:
ERR_CONNECTION_REFUSED
On the previous version of this project on a different repository loaded it was accessible via these URL's. This project has been updated to Rails 5 but dont know why it is listening on TCP rather than HTTP. Any suggestions?
As it has been already suggested, make sure that the server is bounden to 0.0.0.0 so that all interfaces can access it.
You might try:
RAILS_ENV=development bundle exec rails s -b 0.0.0.0

Resources