luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.57k stars 156 forks source link

Multi-thread support #1806

Open notramo opened 1 year ago

notramo commented 1 year ago

Crystal has multi-thread support. Is it possible to enable it for the server executable?

jwoertink commented 1 year ago

I actually haven't played with the multithreading yet because it's still behind a preview flag, so I've been treating that like an experimental feature. It would be cool if Lucky ran with the multithread support, but I haven't tried it out yet.

notramo commented 1 year ago

Does it require lot of work?

jwoertink commented 1 year ago

I have no clue, to be honest :man_shrugging: I've never used multithreading, so I'm not sure if it works, or if it doesn't and what it would take to make it work.

For extra performance, I'm currently using https://github.com/jwoertink/lucky-cluster so I can boot multiple instances on the same server. Instead of using 1 server with multi thread, I'm using 8 servers with single thread :laughing:

mdwagner commented 10 months ago

I see this question get brought up on the Crystal forum sometimes, and it usually comes down to: Yes, it's supported, but it's behind a preview flag, because they're not confident the standard library will run with it well, since it was not designed for multithreading.

I don't think this will get much attention until Crystal enables it completely, and they have at least run it through it's paces with the standard library.

In the meantime, you can always horizontally scale, which is usually a better approach in practice.