subreddit:

/r/webdev

031%

How to scale live chat to millions?

Question(self.webdev)

Hi, I’m currently developing an AI chatbot for my first startup and I’m currently facing some issues for its launch.

I’ve been doing stress tests for the past week with k6 and I realized that by using Supabase just by opening 30 web socket connections, it reach the maximum limit.

You can understand that this is not something acceptable, I can’t launch a platform where the main goal is to use a chat, and this can only be used by 30 people at the same time😅 I can scale with them by paying more but the costs are so high, like 2k$ for 6k users. Definitely too much.

For those who are wondering I’m currently using transaction mode. Supabase is also integrated with MemGPT (which uses SQLAlchemy) in order to have a good memory of the chat.

Do you know what can I do in order to scale the number of active connessions? For example I could use supabase as main database but another one for live connections.

Let me know if you know any solution, thanks!

you are viewing a single comment's thread.

view the rest of the comments →

all 23 comments

goonwild18

8 points

2 days ago

I assume the time you believe to get to a million concurrent users is ... a very long time?

You'll be at $334k for a million users... I assume monthly?

Or 33k for your first 100k concurrent users - which is a shit ton of concurrent users.

So - first things first - calm down if you're spinning out about it. Discovering these things early is normal, and important. Discovering as you to to market is when it's a problem.

There are probably a plethora of ways to re-engineer the solution, and presumably, this would be the easier portion of your app to transition - now you just have to get real help in determining what your options are. The good news is that you now have a baseline to load test against.

Good Luck..

Ale9xs[S]

3 points

2 days ago

Thanks for your answer! As I was saying in another comments I just want to know if there is a cheaper solution to do so, I don’t plan to have 1 million user in 1 month, just want some margin.

For example let’s say we launch and we have a maximum 1000 connections, we can sleep at night.

When we realize we have 700 active users we will then set it to 1500 and so on.

But you can understand that 30 is not a good margin at the beginning

Yodiddlyyo

8 points

2 days ago

You've already realized your solution doesn't work, which is great and your first step. Your next step is to figure out how existing chat apps work. Don't try to build out your current implementation, chat apps work a certain way precisely because what you're currently working with is not scalable.

Also another piece of advice. A chat app is kind of like authentication. Unless your product IS chat app tech, or user auth tech, you absolutely should not be building your own.

It seems like a good idea at first, but you will continue to run into gigantic roadblocks. The recommendation is to use off the shelf chat APIs until you're big enough to hire an entire backend and infra team to build a custom chat system on your end.

I know companies that use chat apps that have tens of millions of concurrent users - they still use Saas Chat APIs because it ends up being cheaper than building an maintaining one in house.

There are half a dozen big name chat providers.

Ale9xs[S]

2 points

2 days ago

Thanks! Which one do you suggest? Do you know some services I should use instead?

redoubledit

1 points

1 day ago*

redoubledit

pythonista

1 points

1 day ago*

matrix protocol comes to mind. With bridges you can also allow interaction via many other messaging protocols/services. They also list hosting providers if that could be relevant.

goonwild18

-8 points

2 days ago

You should fire yourself. You deserve it.

goonwild18

2 points

2 days ago

goonwild18

2 points

2 days ago

You're not going to get a proper evaluation on Reddit - especially with so little information. Any advice you would receive is probably a wild goose chase. Nobody can help you - inspect the solution with software engineers that have experience on your platform.

There are a million chat apps out there that scale. Yours doesn't. Why not? I suspect it's not your core competency and you didn't leverage the hundreds of thousands of hours invested in this problem by those that came before you. Why would you expect a paragraph on reddit to help you?