-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Redis Pub/Sub #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
rack hostname do | ||
append preload "preload.rb" | ||
endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:#{port}") | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to place this file at the top level of the repo (not config/falcon.rb
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. falcon host
does not know about sub-directories like config
.
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I specified --api
when running rails new
, but WebSocket should work fine too, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be fine.
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like domain logic, so I'm not sure if it's appropriate to write it in Controller. However, since it calls methods of connection
instance, I still think Controller is the most suitable place for it, rather than Model or ServiceObject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the design is okay, as the controller is focused on this particular use case. I think if you ended up with a more complex design, or wanted to isolate the logic for the sake of testing, you might prefer to use a service object.
@@ -0,0 +1,3 @@ | |||
server1: bin/rails s --port=3001 --pid=tmp/pids/server1.pid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I use falcon serve
instead of bin/rails s
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, bin/rails s
uses Rackup which is very sub-optimal.
@@ -1,10 +1,7 @@ | |||
Rails.application.routes.draw do | |||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html | |||
root "home#index" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to use a reverse proxy like Nginx, which handles HTTPS termination, so I don't think there's a need to connect to the Rails app using HTTP/2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP/2 has a number of benefits, including the ability to handle far more WebSocket connections per HTTP network connection. HTTP/2 between the browser and the server must use TLS, but between servers it could be plain text HTTP/2. I'm not sure if nginx supports that.
Whether that is useful or not will depend on your scale requirements. Maybe you can comment on the number of active users you are hoping to support and the kind of deployment environment (number of servers, server hardware, etc) and I can give you more feedback.
* ... | ||
``` | ||
$ bundle exec falcon host | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a production environment, is it sufficient to simply start with bundle exec falcon host
regardless of the server's CPU core count? Even if a large number of Fibers are created, will there still only be a single Ruby process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default bundle exec falcon host
will start one server process per processor core, and one event loop per server process, which can handle multiple inbound requests.
If you only want a single process, you will need to configure count
in your falcon.rb
file https://socketry.github.io/falcon/source/Falcon/Environment/Server/index.html#Falcon::Environment::Server#count.
Uh oh!
There was an error while loading. Please reload this page.