Replies: 8 comments 19 replies
-
Wow that's an awesome summary with really great diagrams. My main focus right now is Rack 3, after that I'll move on to Rails and we will solve any of the issues that still exist there. The recent work with rails/rails#43596 will help set the stage for connection per fiber. Right now with AR, the worst case is you will have one connection per thread which means every incoming request (fiber) on the thread would contend with each other (over a single AR connection). While it works, if you are database bound, it is less than ideal. That's based on last time I checked the state of Rails, but it has changed, I don't know if #43596 made it into Rails 7 - and I haven't evaluated the impact of it yet. There is also work going on in the database backends, e.g. The MySQL gem is a little harder because the actual C interface is insufficient, but |
Beta Was this translation helpful? Give feedback.
-
Thanks for this great discussion. I wanted to chime in to say that I'm very happily using Rails + Falcon in production, but without a database. IIRC @ioquatix had suggested considering https://github.com/socketry/db but I understand that some work has gone into making ActiveRecord work better when running with Falcon, and sounds like more is coming, which is great news. I wanted to point out also some helpful discussion here: rails/rails#44219 (comment) I'm hoping @ioquatix can clarify the "entire request" vs "part of the request" question, but my (naive) understanding is that ActiveRecord would be operating a single connection, as opposed to a connection pool. If that's the case, it's not really a question of "consuming a fiber" vs not using a connection pool. In my case, I'm just about to add a database to my app, but I was thinking of using |
Beta Was this translation helpful? Give feedback.
-
@tleish Can you provide some more details about the asynchronous Ruby proxy server?
Any code samples you can share will be of great help. |
Beta Was this translation helpful? Give feedback.
-
Q: Is it using any framework? Q: Does it proxy all routes or selected routes? Q: Are the calls from proxy server to Rails app through HTTP? If so, how is auth handled? Both servers can access Redis (sessions), but only the Rails server accesses the DB. Rails server never sends requests to Falcon or 3rd Party server to maintain low latency. |
Beta Was this translation helpful? Give feedback.
-
👋 I would like to understand if there is any update. |
Beta Was this translation helpful? Give feedback.
-
Soooo I just replaced
I'm stoked! But also I have.... questions:
|
Beta Was this translation helpful? Give feedback.
-
FWIW I was running falcon on fly.io and I noticed 2 things:
I can't help but wonder if a forking + evented model like rainbows would be worth trying. not sure what to make of the memory footprint |
Beta Was this translation helpful? Give feedback.
-
Hi guys! I quickly went through this conversion and would love to learn more. Here's what I got so far:
If I got it correctly, could you tell me more info as to what makes it so hard to make the ActiveRecord compatible? Would love to learn about this complexity and fill the gaps in my head. Also found this repo: https://github.com/socketry/db-active_record. Does it imply that such driver is possible but requires a lot of testing and effort? |
Beta Was this translation helpful? Give feedback.
-
QUESTIONS:
DETAILS:
A recent article on ideas for improving the Ruby JIT compiler sparked a conversation between devs in Hackernews discussing different approaches to making a Ruby on Rails application run faster. If a Rails app is CPU bound, then improving the JIT might help. However, if the Rails app is primarily I/O bound, then this approach might not make much of a difference.
A former Shopify developer wrote:
We avoid I/O delay by deploying two servers. A Rails server and an asynchronous Ruby proxy server (falcon).
Standard Request
An example of a standard internal request looks like this.
3rd-Party Request
If a user interaction requires I/O delay from a 3rd-party API, the sequence looks like this.
Using Falcon as an asynchronous proxy prevents our Rails server resources from getting tied up while waiting for 3rd party I/O. For us, this has scaled very well. As you can see, the main downside is the additional complication. I'd love to combine Falcon/Rails into a single server to simplify this. However, it's unclear to me the current status/roadmap for making this work, especially for a legacy app.
In researching this I've found the following:
In response to the above article, @ioquatix responded:
What does "hugely limited" mean? Does it just mean that ActiveRecord would be synchronous, while a 3rd party request could be asynchronous and release the fiber while waiting for response? This is how our stack works today, but this would just mean we could consolidate to a single server.
I also found Falcon Guides > Rails Integration which does not mention any gotchas or limitations of ActiveRecord.
I know there's been some recent changes to Ruby 3 and fibers, is it advised to wait for these to be deployed?
In my research I also remember reading a comment by @ioquatix suggesting Falcon as experimental and not to be used for production (which we currently are).
Beta Was this translation helpful? Give feedback.
All reactions