Closed trevorturk closed 3 months ago
I've noticed the same, but looks like the problem is not in the memory consumption but in wrong instances count.
Falcon 0.44.0+ started ignoring count
option in configuration and runs forks count = processors count (as if option is empty). As a workaround you can explicitly override instances count using ASYNC_CONTAINER_PROCESSOR_COUNT
environment variable.
cc: @ioquatix
Ah, perhaps in the move to async-service in https://github.com/socketry/falcon/pull/226 that was (inadvertently?) dropped, but I'm not sure if the plan is to migrate into a new config style? I think we should probably still support count, or raise an error if it's being used and shouldn't be?
I dug a bit and see Etc.nprocessors
is used, but this reminded me of the discussion around Puma in Rails here: https://github.com/rails/rails/issues/50450#issuecomment-1881585649 so I checked and imo we should consider not using that system and instead defaulting to 1 or something. See for example on my Heroku Standard-1x Dyno which I believe should only run 1 Falcon process where I'm likely being assigned 1 virtual CPU on a machine that has 8?
$ heroku run rails console
Running rails console (Standard-1X)
irb(main):001> Etc.nprocessors
=> 8
Somewhat of a separate issue, but if we need to move over to the new configuration style, we'll need to figure out what changes are needed from the old style. For example my config for Heroku is currently:
#!/usr/bin/env -S falcon host
load :rack
hostname = File.basename(__dir__)
port = ENV["PORT"] || 3000
rack hostname do
append preload "preload.rb"
cache false
count ENV.fetch("FALCON_COUNT", 1).to_i
endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:#{port}").with(protocol: Async::HTTP::Protocol::HTTP11)
end
...and I'd want to make sure to disable caching etc.
This looks like a bug I will investigate it today.
The count
was not used when creating the container:
It's using container_options[:count]
. We can add count
to the default container options which should fix this.
This should be fixed in v0.45.1 - please let me know if you have any issues.
Thank you! ☺️
Confirmed fixed for me. Thank you for the quick fix!
Confirmed fixed for me too. Many thanks!
I think there's an issue with Falcon 0.45.0 where it uses significantly more memory as opposed to 0.43.0.
I've isolated a diff of the minimal Gemfile(.lock) changes for my app here:
Screenshot of my memory usage metrics on Heroku:
Please let me know if there's anything I can do to help debug! Thank you!