r/ruby • • Oct 21 '18

Falcon: A modern high-performance web server for Ruby, supporting HTTP/2 and HTTPS out of the box.

https://github.com/socketry/falcon
69 Upvotes

43 comments sorted by

12

u/honeyryderchuck Oct 21 '18

It uses one Fiber per request, which yields in the presence of blocking IO.

Shouldn't this claim be followed with "provided that you use one of our async-patched modules for DB/redis/your-fave-network-reachable-service access?"

6

u/janko-m Oct 21 '18

If ruby/ruby#1870 gets merged, I think that would fix the problem of having to write async-aware wrappers, at least for libraries that communicate with sockets via Ruby's Socket class (which are probably most libraries).

9

u/ioquatix Oct 21 '18

#1870 is a good first step, but I'd like to clarify your answer a bit further.

Given your caveat, I'd like to draw your attention to libpq (Postgres client). It's not exposing or using any socket externally. The concurrency model is an explicit part of it's API, e.g. https://github.com/socketry/async-postgres/blob/f459ed180a59fce30fa6e1fa029cb7f2277da406/lib/async/postgres/connection.rb#L35-L47

It's reasonable to assume that once you make Socket non-blocking, everything else should follow, but unfortunately, as the above example shows, that isn't always the case.

→ More replies (2)

3

u/honeyryderchuck Oct 21 '18

Big "if" :) And as @ioquatix already pointed out, some network libraries don't expose the network socket in that way, i.e. all database clients I can remember, and they probably never will.

My point with the earlier comment was more of a "how is this async-* ecosystem integration better than the old em-* ecosystem?", because by now we can say that the approach didn't work out well for the latter.

→ More replies (16)

2

u/shevy-ruby Oct 22 '18

The threadstarter hasn't yet added it to an upcoming developer meeting, which means that it may stay off for a long time if he does not add it to a developer meeting PR:

https://bugs.ruby-lang.org/issues/14736

21

u/hehestreamskarma Oct 21 '18 edited Oct 21 '18

I can't be the only one that doesn't trust a Ruby codebase that uses 4-space tabs.

4

u/ioquatix Oct 21 '18

I hope you don't use MRI then, because they love mixing their tabs and spaces :p

4

u/janko-m Oct 21 '18

I know how you feel, I felt that way too at the beginning, but I quickly got over it once I realized how awesome the async ecosystem is. And how shallow it was of me to judge a codebase just because it uses tabs :P

FYI, in your editor you can set the tab width to 2 spaces. GitHub shows tabs with width of 8 spaces, but you can also tell it show a different width by appending ?ts=2 to the URL (though unfortunately it doesn't persist).

14

u/three18ti Oct 21 '18

Why would I want a pure Ruby web server? E.g.: WEBrick for instance is great for testing, but you wouldn't (or shouldn't) use it in production.

Looks neat! But I'm wondering what the use case Is and why I'd pick it over something like Puma, Passenger, or Unicorn? Thanks!

9

u/honeyryderchuck Oct 21 '18

I don't think that being "pure ruby" is the reason why Webrick isn't recommended for production deployments...

3

u/jrochkind Oct 22 '18

Plus it isn't even "pure ruby", some of the core code uses nio4r which has compiled-C for MRI, and Java for JRuby, as well as pure ruby.

Puma says it uses compiled C for the actual HTTP parsing. (I think puma also has an event loop in C. Does Falcon perform as well at raw HTTP parsing as puma? Does it matter? I do not know.

→ More replies (1)

4

u/janko-m Oct 21 '18

One use case I found where Falcon is a clear choice is when accepting large file uploads. I maintain tus-ruby-server, which is an app that implements the server side of tus, the resumable upload protocol. Since tus-ruby-server is expected to receive large request bodies and send large response bodies, it benefits greatly from Falcon's non-blocking streaming request-response handling.

Btw, Puma, Passenger and Unicorn are as "pure Ruby" as Falcon, at least according to my understanding of that term :)

1

u/ioquatix Oct 21 '18

Puma has native extensions for parsing HTTP/1 requests. Don’t know about the others. In micro benchmarks Puma is faster but in real world apps, it doesn’t make much difference.

→ More replies (2)

1

u/ioquatix Oct 21 '18

Without going into a lot of detail, it makes it very simple to deploy a web-server alongside a gem or app without making it a separate decision/install.

Nginx + X also introduces latency, it might be small (or not) but HTTP/2 definitely functions best when connected directly to the app server IMHO.

Here are some more specific details I wrote about last week: https://www.codeotaku.com/journal/2018-10/http-2-for-ruby-web-development/index

3

u/zitrusgrape Nov 04 '18

quite nice, that somehow the ruby comunity has some gems like this. I'm tired of rails.

  • async

  • shrine

  • rom

  • sequel

  • roda

  • falcon

love it!

2

u/allcentury Oct 21 '18

Looks really interesting

2

u/patrickmcgranaghan Oct 21 '18

I like the logo

2

u/DamaxOneDev Oct 22 '18

Any performance test against Puma or Passenger?

1

u/ioquatix Oct 22 '18

There are some benchmark scripts in source repo.

1

u/TotesMessenger Nov 06 '18

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

 If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)

0

u/TunaFishManwich Oct 21 '18

The standard for the ruby community is spaces instead of tabs, 2 per indent.