Re:Ask HN: How hard is it to build a B2C chat?
by edweis on Wednesday June 05, 2024 @11:55AM
(#40586504)
I see, thank you for your input.
We are not expecting a huge traffic as we launch, if the heap size is an issue we can always buy a bigger for now.
When the cost are exceeding $200/month, it will probably be a better solution indeed to change the technology to be memory efficient and async.
Re:Ask HN: How hard is it to build a B2C chat?
by karpovv-boris on Wednesday June 05, 2024 @04:41PM
(#40590337)
| something I'd do for fun for learning - Yes. The answer that comes above is good from web specs pov (or theory in general), otherwise it's not, as it complicates things.
All major langs already have good support async/await, and where is not requirement to rewire your brain to use it. Also, you don't have to write a lot of lines to dealing with websockets, just take lib which build on top of websockets.
Anyway. If you need chat with simple feature set (1 to 1, text, imgs), then, as mentioned below, it is not hard to write it in just two weeks max. Otherwise, for chat with some specific feature set, it is actually better to buy one.
Imagine for instance a web based chat program: if you were just using ordinary web requests (not websockets) the front end would have to poll the back end periodically and you can pick your polling rate to trade off wasted polls vs latency to receive polls. I can picture making a chat app based on polling that stores the conversation in (say) PostgreSQL, but would be awkward. (At launch Twitter was built like this but it wasn't long before the system was crumbling from the load)
A chat app that uses websockets on the other hand could transmit messages almost instantly without any wasteful polling. However you are getting into the systems programming area instead of applications programming. If I were going to do it I'd consider (1) Java with threads, (2) Erlang/Elixir, or (3) Python with asyncio. Either way there would be some shared data structure in RAM about which messages get forwarded to who and it is important that it can't be screwed up by multiple users updating it.
Personally it's something I'd do for fun for learning but it's in another class than the routine work that most webdevs (including myself) do. So I am not surprised that the open source choices look thin and the commercial products are expensive.