mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: springzhong <davidmahorse@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: out of memory error from kernel when I open hundred of thousands of TCP connections
Date: Thu, 04 Nov 2010 07:07:01 +0100	[thread overview]
Message-ID: <1288850821.2718.47.camel@edumazet-laptop> (raw)
In-Reply-To: <1288850316.5575.1.camel@zhongjiu>

Le jeudi 04 novembre 2010 à 13:58 +0800, springzhong a écrit :
> The source of serve is like:
> ListeningThread listeningThread(this, nPortNum);
> listeningThread.nPortNum=6475;
> listeningThread.Start();
> ListeningThread listeningThread2(this, 6476);
> listeningThread2.nPortNum=6476;
> listeningThread2.Start();
> ListeningThread listeningThread3(this, 6477);
> listeningThread3.nPortNum=6477;
> listeningThread3.Start();
> ListeningThread listeningThread4(this, 6477);
> listeningThread4.nPortNum=6478;
> listeningThread4.Start();
> 
> The source of client is like:
> for (int i = 0; i < 60000; i++)
> {
> this->Connect("127.0.0.1", nPortNum, false, pClientSocket);
> this->Connect("127.0.0.1", 6476, false, pClientSocket);
> this->Connect("127.0.0.1", 6477, false, pClientSocket);
> this->Connect("127.0.0.1", 6478, false, pClientSocket);
> }
> 
> I want to test the maximum tcp connections of linux in my netbook with
> 2G memeory.
> But I just found It cannot exceed 240000 connections.Then an 
> "out of memory error" occured. But it looks like there is still a lot of
> free memory in my computer.
> 
> I want to rechange the kernel to accept more TCP connections like one
> million tcp connections in my network.
> But I find there are too many source codes in it. 
> Could you give me any suggestions?
> I have changed my environment like this with epoll:
> /etc/security/limits.conf
> * soft nofile 802400
> * hard nofile 802400
> # End of file
> 
> cat /proc/sys/fs/file-max
> 2204218
> 
> cat /etc/sysctl.conf
> net.ipv4.ip_local_port_range = 1024 65000
> 
> cat /proc/sys/fs/epoll/max_user_watches
> 2500873
> 
> It is not the limitation of file ids of linux.It is an error from kernel
> of LINUX
> 

If you run a 32bit kernel, you probably hit a LOWMEM limit : sockets
structures are kernel structures, allocated from LOWMEM zone.
This is about 900 MBytes in 32bit kernel, even if you have 4GB of total
ram.

grep Low /proc/meminfo

If your netbook has 2GB of memory, you could compile a kernel with a
2G/2G User/Kernel split

CONFIG_VMSPLIT_2G=y




      reply	other threads:[~2010-11-04  6:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04  5:58 springzhong
2010-11-04  6:07 ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288850821.2718.47.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davidmahorse@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®