public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ZONE_NORMAL memory exhausted by 4000 TCP sockets
@ 2006-11-06  6:07 Zhao Xiaoming
  2006-11-06  7:34 ` Eric Dumazet
  2006-11-06 10:13 ` Arjan van de Ven
  0 siblings, 2 replies; 20+ messages in thread
From: Zhao Xiaoming @ 2006-11-06  6:07 UTC (permalink / raw)
  To: linux-kernel

Dears,
    I'm running a linux box with kernel version 2.6.16. The hardware
has 2 Woodcrest Xeon CPUs (2 cores each) and 4G RAM. The NIC cards is
Intel 82571 on PCI-e bus.
    The box is acting as ethernet bridge between 2 Gigabit Ethernets.
By configuring ebtables and iptables, an application is running as TCP
proxy which will intercept all TCP connections requests from the
network and setup another TCP connection to the acture server.  The
TCP proxy then relays all traffics in both directions.
    The problem is the memory. Since the box must support thousands of
concurrent connections, I know the memory size of ZONE_NORMAL would be
a bottleneck as TCP packets would need many buffers. After setting
upper limit of net.ipv4.tcp_rmem and net.ipv4.tcp_wmem to 32K bytes,
our test began.
    My test scenario employs 2000 concurrent downloading connections
to a IIS server's port 80. The throughput is about 500~600 Mbps which
is limited by the capability of the client application. Because all
traffics are from server to client and the capability of client
machine is bottleneck, I believe the receiver side of the sockets
connected with server and the sender side of the sockets connected
with client should be filled with packets in correspondent windows.
Thus, roughly there should be about 32K * 2000+ 32K*2000 = 128M bytes
memory occupied by TCP/IP stack for packet buffering. Data from
slabtop confermed it. it's about 140M bytes memory cost after I start
the traffic. That reasonablly matched with my estimation. However,
/proc/meminfo had a different story. The 'LowFree' dropped from about
710M to 80M. In other words, there's addtional 500M memory in
ZONE_NORMAL allocated by someone other than the slab. Why?
   I also made another test that the upper limit of tcp_rmem and
tcp_wmem being set to 64K. After 2000 connections transfering a lot of
data for several seconds, the linux box showed some error messages
such as error allocating memory pages, etc. and became unstable.
   My questions are:

1. To calculate memory request of TCP sockets, is there any other
large amount of memory requested besides send and receive buffer?
2. Is there any logics that emploied by TCP/IP stack that will
dynamically allocating memory pages directly instead of from slab?

Thanks!

Xiaoming.

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: ZONE_NORMAL memory exhausted by 4000 TCP sockets
@ 2006-11-07  8:06 Al Boldi
  0 siblings, 0 replies; 20+ messages in thread
From: Al Boldi @ 2006-11-07  8:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, linux-net

Zhao Xiaoming wrote:
> The latest update:
>     It seems that Linux kernel memory management mechanisms including
> buddy and slab algorisms are not very efficient under my test
> conditions that tcp stack requires a lot of (hundreds of MB) packet
> buffers and release them very frequently.
>     Here is the proof. After change my kernel configuration to support
> 2/2 VM splition, LOMEM consumption reduced to 270M bytes compared with
> 640M bytes of the 1/3 kernel. All test conditions are the same and
> memory pages allocated by TCP stack are also the same, 34K ~ 38K
> pages. In other words, 'lost' memory changed from ~500M to ~130M.
> Thus, I have nothing to do but guessing the much more free pages make
> the slab/buddy algorisms more efficient and waste less memory.

I kind of agree, and always compile for a 2G/2G VM split, as this also seems 
to affect certain OOM conditions positively.

What isn't quite clear though, why is the 2G/2G VM split not the default?


Thanks!

--
Al


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2006-11-07  8:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-06  6:07 ZONE_NORMAL memory exhausted by 4000 TCP sockets Zhao Xiaoming
2006-11-06  7:34 ` Eric Dumazet
2006-11-06  8:10   ` Zhao Xiaoming
2006-11-06  8:48     ` Eric Dumazet
2006-11-06  9:03       ` Zhao Xiaoming
2006-11-06  8:59   ` Zhao Xiaoming
2006-11-06  9:22     ` Eric Dumazet
2006-11-06  9:46       ` Zhao Xiaoming
2006-11-06  9:49         ` Zhao Xiaoming
2006-11-06 13:33         ` Eric Dumazet
2006-11-07  2:48           ` Zhao Xiaoming
2006-11-07  5:53             ` Eric Dumazet
2006-11-07  6:08               ` Zhao Xiaoming
2006-11-06 16:36   ` Stephen Hemminger
2006-11-07  2:50     ` Zhao Xiaoming
2006-11-07  6:00       ` Zhao Xiaoming
2006-11-06 10:13 ` Arjan van de Ven
2006-11-06 10:21   ` Zhao Xiaoming
2006-11-06 10:21     ` Zhao Xiaoming
  -- strict thread matches above, loose matches on Subject: below --
2006-11-07  8:06 Al Boldi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox