Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What kinds of cool things are people doing with Elixir these days, where they feel it's a really good fit for the problem domain?


Just wrapped up a live translation feature that watches an HLS live stream, live transcribes with whisper and then translates into 18 languages. Heavy use of OTP: supervision trees for each stream, ports for managing ffmpeg and receiving audio, async tasks for concurrently submitting chunks to translation API, etc. Transcription and translations provided in real-time via LiveView to about 4,000 viewers.

Little over 3 weeks from `mix new` to the live event. Not sure how I could have done it so easily without OTP and LiveView.


That's really cool. Managing ports is something I've done in elixir yet, but managing ffmpeg through elixir could be very useful for a few things in my current area of focus.

Can you share any details of how that works? E.g. do you operate on a single HLS chunk at a time, or can you get ffmpeg to separate a continuous audio stream, etc?


davidw is right that ports are somewhat limited, but I haven't had much trouble doing what I need with FFmpeg in particular. I used the bash wrapper from the docs for Port [^1] and it has worked well.

When a stream starts I start a supervisor that then starts a GenServer to manage the port. On init a port is started for FFmpeg (using the above bash wrapper) with args that sends 16-bit PCM audio back to the port through the `handle_info/2` callback.

When a new live HLS segment is downloaded by FFmpeg the entire segment's audio is sent to the GenServer all at once (could be a few handle_info/2 calls, but it happens quickly). Since I want to work in small fixed chunks, I send the segment's audio to an AudioBuffer GenServer (started as a sibling under the same supervisor). This buffer uses binary pattern matching to segment the audio in chunks exactly 2 seconds long while keeping any remainder in the GenServer's state for the next buffer event. I then send the chunks to another ChunkBuffer GenServer that pops chunks at 2-second intervals for processing.

Since everything is supervised, if (when...) FFmpeg crashes the supervisor just restarts it. Meanwhile, the audio in the buffer is still processing and nothing goes down. There might be a duplicate word or two in the transcription if the restarted port processes a segment again, but everything keeps running smoothly.

For even more reliability, I have the application running clustered across four locations in the US, EMEA, and APAC using libcluster[^2]. The stream supervisor is started under a Horde.DynamicSupervisor[^3] with a custom distribution strategy. The strategy prefers the region closest to the company HQ, but if it goes down, the processes will be restarted in another region.

[^1]: https://hexdocs.pm/elixir/1.13.4/Port.html#module-zombie-ope...

[^2}: https://github.com/bitwalker/libcluster

[^3]: https://github.com/derekkraan/horde


Absolutely fantastic write up - thank you so much. I will go away and do some further reading!


https://github.com/saleyn/erlexec is pretty good for handling external processes. The builtins aren't quite there if you have more complex use cases.


We built a social network for social justice work, with posts, likes, shares, and the like. Elixir and Phoenix are a really good fit for the problem domain i.e. lots of concurrent users, high scalability via built-in balancing and queuing, the "let it crash" concept for lots of backend APIs such as image processors that sometimes fail. And LiveView is superb for fast interactivity.


Got a link?


I'm building a multiplayer real time web based game (io style, 2 ticks per second, so not 64 like a true realtime game). It seems to work quite well so far. I'm using https://github.com/woutdp/live_svelte for the frontend with pixi.js for the rendering.


How's the svelte + LiveView integration been working out for you thus far? I still find a lot of issue with trying to do a bit of work in JS-land for things where I want to have no latency, but find it can sometimes be a challenge managing everything through various LV hooks.


I'm biased since I made LiveSvelte, but it works quite well! I made a video to showcase some of its features here: https://www.youtube.com/watch?v=JMkvbW35QvA

Working with it in a real project now, instead of toy examples like in the video, it works really well for when you have highly complex components that rely on quite a lot of local state.

What you'll find is the developer experience is quite nice with LiveSvelte compared to JS hooks.


Thank you for your contribution and for this video! Going to give this a try in the near future.


This is quite cool. Can it enable optimistic UI updates?


Yes :)


It's particularly good when you have concurrent users. Also, if you just have a web app that won't need other clients then LiveView gives you SPA-style development without the need to write a web-API layer.

Personally, I use it for any web app I'm making. It's a very simple language at its core and is just as good for tiny things as it is for large ones.


I know a lot about what the BEAM is good for, I'm curious about actual things people are doing with it.

The last time I used it seriously, we used Erlang as the high level language for these: https://www.icare-world.com/us/product/icare-eidon/ and it was a great fit for that kind of semi-embedded environment.


Ah, well, personally I'm not doing anything other than web apps.

A slightly cool thing its enabled is that I have a monolith with a single microservice. All the microservice does is process messages from the main app to process images, upload them to S3, then notify back when it's done. The cool thing is that they can be run on two separate connected BEAM instances communicating via the built-in message passing with no need for an HTTP API. I haven't deployed this, yet, though.

Maybe that's still not what you're looking for but I was really happy when I figured out I could do that :D


There's Nerves for semi-embedded.

https://nerves-project.org/


Anything soft real time is a great fit. We push data to clients every 3 minutes or when specific events arrive. It was super easy to build with out of the box tools and just works.


Wrote the basics of a MMO emulator for metin2 in it with horde for multi node Game Server distribution (per map a process) and ranch for connection pooling, basic stuff like login and walking around, and having monsters spawn (it's a hack n slash MMO) multiplayer and PvE combat works, stopped at that point to further develop it deeper, since I kept musing about to advanced feature wishes like behavior trees for monsters /bosses

Elixir felt all around like s perfect fit for it , apart that some faster deep mutations likely would have been had to be ported to rust or c because the way I wrote it having 250 players on a single map walking around and seeing each other close by caused huge latency but no crashes Scaled well across multiple machines and lots of players as long as they did not all bog down the same map process :) Didn't even had to think s lot about how I structured it for the current state of development it was basic rapid iteration with mostly live recompilation on changes without having to restart anything https://gitlab.com/zen_core/zen_core


I built a real-time updating internal test bed reservation system for the company I am employed by. It’s mostly a LiveView app with some external modules and js hooks scattered throughout.


I’m building a product in the media world. Elixir powers our webserver, that’s connected to NVIDIA Jetson devices, all using elixir for coordination and talking over UART to serial components. We also plan to do vision and ML workloads in the applications in the near future


We use Elixir as the backend for a lot of services that need reliability and performance in healthcare specifically on the pharmacy side. One such use case is pricing medications at the point of prescribing to enable conversations between a provider and a patient.


Anything with concurrency or where you'd normally use LiveSockets, but man, I like using it for everything.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: