1

I'm trying to understand how servers handle many requests when they start to run out of RAM.

Let's say you have a server with 1GB of idle RAM. Let's pretend it was bombarded with 1024 requests in 1 second and each request sent over 1MB of data. Let's pretend that the server was dumb and it didn't send a response back to the client until all tcp packets were loaded in memory, and didn't deallocate until completely responding to all requests.

Let's also pretend that there was no additional memory overhead occurred besides reading the request into memory.

At this point, the server has no free memory. What would happen if it got 1024 more requests the next second? Even if the server had finished sending everything back to the client, I would imagine that with garbage collection/deallocation of memory could take much longer than the amount of time before the next 1024 reqs come in.

Would the server just miss all the tcp packets that were hitting it on it's port? If so, would the client perceive this as network congestion or a total network failure? If they perceived it as network congestion and if some packets were going through, would the client try to resend potentially dropped packets? How would the server handle this?

  • 2
    Does this also assume zero modern memory management and the absence of virtual memory, page tables, and disk swapping? – Dave Nay Aug 25 '18 at 1:13
  • Thanks for responding Dave. To clarify I'm more interested what happens on the network-side than actual memory management piece on the server-side. But, since you mentioned it, on the memory-side, say we increase it to 1GB per request, what would become the bottleneck and how would most computers respond? – chapinkapa Aug 25 '18 at 1:30
  • Why did you assume the server can't just serve them one at a time in sequence? – whatsisname Aug 25 '18 at 2:26
  • 2
    The server would do whatever it was programmed to do in that case. – Jörg W Mittag Aug 25 '18 at 7:45
  • 2
    This is analogous to the question of how a (D)Dos works. In this case it is a Layer 7 attack instead of typical layer 4 attacks. I suppose the request on the client side to simply time out. – Thomas Junk Aug 25 '18 at 14:51
2

Its not totally clear what you are asking. If you want the technical details then its going to depend on a specific OS, network card, driver, software combination.

In general TCP is self limiting, if a packet comes in and the server cant handle it on the networking level for whatever reason then the packet will be resent, or the connection will fail.

If the network, network card, driver and OS are all ok with the amount of incoming data, but the software cant handle it, then it might crash with an out of memory exception.

But more likely it will just slow down its processing of the data. causing the network buffer to fill up and hence the TCP stream to slow down through its self limitingness.

If it was UDP then the packets would be dropped

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.