4 ms·
Its funny how most languages have this whole separating between microservices and monoliths. Having worked with elixir for the last 5 years, One of its biggest
by cultofmetatron 4y ago
Its funny how most languages have this whole separating between microservices and monoliths. Having worked with elixir for the last 5 years, One of its biggest benefits is the ability to have a microservice deployment while having a monolithic codebase.
It comes with a reasonably good internal pubsub system and vm linking right out of the box. And the built in application supervisor makes it trivial to spawn thousands of threads on one machine, each with their own independently allocated heap, that can be mounted under a supervision tree.
Want to create a microservice? just make a file, inherit the GenServer and add it to your application tree in your application.ex. Add a library like horde and you can create singletons in your codebase that are microservices. they run as a thread somewhere in your cluster. Just send it a message by nmae and the vm will know where to deliver it.
The end result is the overhead of creating and maintaining a microservice in elixir is about the same as the overhead for adding a new controller.
- vereis 4y agoGuaranteeing a singleton process is a very difficult problem which horde definitely does not solve perfectly mind you. All is well and good until it isn't. We opted for leveraging different mix release permutations deployed on k8s as needed instead. Definitely takes more effort than what you describe, and has its own issues... But imo definitely better understood than fighting weird state with horde
- spion 4y agoElixir (and Phoenix) are truly amazing. I only wish there was a typesystem / spec system better (stricter) than Dialyzer. Or perhaps I am doing something wrong but I couldn't get it to be as strict - if there is a way i'd love for `credo` to force me to adhere to it.
- cultofmetatron 4y agoits unfortunate that elixir's type system isn't too strict. That said, if you want somethign stricter, there is gleam (https://gleam.run/ https://gleam.run/) which has interop with elixir. I haven't tried it myself yet but you could probably embed a service in gleam for specific cases where you need the stricter type checking.
- spion 4y agoYep, I've seen Gleam and I absolutely love the idea, although it seems like its super early stage still. Should play with it a bit more.