lpereira / lwan

Experimental, scalable, high performance HTTP server

Home Page:https://lwan.ws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How memory allocations will work in case of lots of connections?

shivshankardayal opened this issue · comments

Nice work on lwan. I had a question. Consider that lots of connections are made and there are handlers for each connection. Now when the handlers for these connections allocate memory on stack how will stack cope up with all this memory allocation?

Thanks for the answer I was afraid of. The way I see is that even though you need only 500KB memory for 10k concurrent connections in real-world the coroutines will need their own stack. Now the bigger problem is if we allocate the 8 MB default stack(that is stack size for a process on my 64-bit Linux) for one coroutine we are looking at 80G RAM for 10k connections(even if we allocate 512 KB we are looking at 5G of RAM but I do not see this problem going away with large number of connections no matter which design we choose). It becomes even worse when you try to implement something like websocket where the connection has to be kept open for long periods of time.

So what I think is that Seastar may have some solution for this kind of problem though I have not investigated that.

Closing this issue; if you have more questions, feel free to open another or reopen this one.