High capacity scalable server

I am writing some server programs. I notice that I can only connect to the server with a total of 28232 connections(clients) before I get the errno [99] “Cannot assign requested address” from the client program. I am using the same machine to do both operations. It seems like I am reaching some networking limitation outsie of both programs.The server process has a maximum of 6 theads running(well below the thead limit). The client has two theads. When I add another client machine to the testing I can surpass 28232 connections). What limitation am I reaching on the server machine and how can I overcome this limitation. Again when I add a client machine to the testing, I can achieve more than 28232.

System Setup:
SUSE 11.1 64 bits
ulimit nofile=150000

THKS,
uans

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What makes you think this is a server limitation? I do not know that it
is not, but you stated yourself that you could get more than 28232
connections (on the server) by adding another client.

Good luck.

uans wrote:
> I am writing some server programs. I notice that I can only connect to
> the server with a total of 28232 connections(clients) before I get the
> errno [99] “Cannot assign requested address” from the client program. I
> am using the same machine to do both operations. It seems like I am
> reaching some networking limitation outsie of both programs.The server
> process has a maximum of 6 theads running(well below the thead limit).
> The client has two theads. When I add another client machine to the
> testing I can surpass 28232 connections). What limitation am I reaching
> on the server machine and how can I overcome this limitation. Again when
> I add a client machine to the testing, I can achieve more than 28232.
>
> System Setup:
> SUSE 11.1 64 bits
> ulimit nofile=150000
>
> THKS,
> uans
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLPPVSAAoJEF+XTK08PnB5fSYP/1lm8nxoc7np3H3XRGpG98WV
yukBLM/ovC9hs4KejT6D/9DREBLAvr7q5I4+4cOo3kfvVHcKZsjv+KUtyXKjEoZr
Irra7DvNVwF8uwdf0UUcxgdSQuoS7hB3lH4T9kHzDIwVQYpheZyflw8pmJDF9Zo3
JUb9wGdxdsVuBvtvcSZMyXLq0v+foDGWVsh5z3CMZw37CGAVSF/CqX9CY5nWV+Y6
2Hdj2IW9WFk8CONcVYqkNoTUP9fEXbhyfyEsfVStPznJrJiMLW0Yf09tUmatTxLQ
DxVG4rLo6ltZ1CEYw8/ccJa5v9FUkBgkxxx+SAs2viDrSGrgmLvj7ZcbI0i4EahI
vnwYvg4j/TCGCPyghonE1i8/5hUdlEsugGyjCYSoa4JZ17qWBZTZ1Bj8W9j1C3+Z
fQs7x7UVlCD4z2earr4PVj7agZyEpo7zG7Domqw72g+t4LiOu+fv5wGlXB1K0M34
NbOkqgRpClSyOIbuO/Dx/09brV/+jvIeG5kmX0XecG7jNwwPE2IzaZNFCLy7KZmR
MAS20h1GOwYLqRBUs1sqHUgdytBNCXt89M2AOBl59mgOLGgcxNA7+snJW9OC06/U
AQ5PxwceP+nNGRuaFCLFNFVmUw0gaZiUW63SuQYVjLg2B7fUIYHGcZUDJj580yUV
HMETmoYBTsOrGF/LzzfF
=S877
-----END PGP SIGNATURE-----

Well, since I am running the server and client program on one machine until 28232 connections is reached, what eles could it be.It has to be on the server machine. I hope I am making this clear!

THKS,
uans

I did a search and here what I found:

User wrote:

I once wrote a server program, it prefer a long connection, I mean, accept once then loop read/write, but if client only give once read/write, it can close the client fd no problem. Then I wrote a client a program but it prefer short connection, that is, connect/write/read/close, then the client loop do connect/read/write about 1 millioin times. I found after about 28231 connection, the client exeception with error “Cannot assign requested address - connect(2)”. if I change the client model to long connection, or I change the server model to process only short connection, that is accept/read/write/close the client fd, all is ok, what’s wrong? server and client code attached.

Here was the reply:

The machine ran out of dynamic ports to assign as the source port for the outbound connection. Either get the administrator of the machine to allow a larger range of source ports or ‘bind’ to a random source port chosen over a large range (say, 34000-60000) yourself.

My question is where can I inlarge the port size limit at?

THKS,
uans

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes, that is likely the problem, but it is, as mentioned, still a client
problem. The limit is on the number of OUTBOUND connections. Anyway, if
you really want to do it Google for:

/proc/sys/net/ipv4/ip_local_port_range

The following came up for me as one runtime option, though its setting
will not last across reboots. I have not found where to set the value
permanently for persistence:

http://docs.sun.com/source/817-2180-10/pt_chap6.html

Good luck.

uans wrote:
> I did a search and here what I found:
>
> User wrote:
>
> I once wrote a server program, it prefer a long connection, I mean,
> accept once then loop read/write, but if client only give once
> read/write, it can close the client fd no problem. Then I wrote a client
> a program but it prefer short connection, that is,
> connect/write/read/close, then the client loop do connect/read/write
> about 1 millioin times. I found after about 28231 connection, the client
> exeception with error “Cannot assign requested address - connect(2)”. if
> I change the client model to long connection, or I change the server
> model to process only short connection, that is accept/read/write/close
> the client fd, all is ok, what’s wrong? server and client code
> attached.
>
> Here was the reply:
>
> The machine ran out of dynamic ports to assign as the source port for
> the outbound connection. Either get the administrator of the machine to
> allow a larger range of source ports or ‘bind’ to a random source port
> chosen over a large range (say, 34000-60000) yourself.
>
> My question is where can I inlarge the port size limit at?
>
> THKS,
> uans
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLPRgdAAoJEF+XTK08PnB5x8sP/RyEtab50Vu8lQ/UxV+IoDnu
KELhX+4LOri2uVtEMoSyas6T0cCkw4+Bb5+7NQiRNkCR9B8UENcwUtGBELy2G1Wl
kD4vGKb2juxIX0WzUewEgk8ADL6jyR8va6bfe9tEqX4Hmu1HoXpG6NO/Mg03PFnh
JIcVe7L8UjsCx0UQIU7mwPxeUNF4GzrG12F1U6A76PinZrHM4pZ8PjjYyIJ3F625
+hSk5MvqhBSdPhSa3zVvh3lyTsPiPffP2Vgu4kpKxssQfQEqhAqohekAJacffNWZ
B3z6U0sj8Bz4YOv0j1brGcSPpg3cLkh0B7oqvogKxnLEx8E1uzmTIPnOP0VsqYMU
youAWdv+YrnYHweILHXbAD2CmhTWQnS/u+KZ11FPwJT4DFORwzeFa9JMzMQqP/TI
a0WD8uLIFx1ScjNHWhCkBLLMOJdpKb8xYBOZyG3yVIrDUmZcGQWYMsi+1/5q3Uc2
LPSiiodJ5bMKlZU+myIxPTWeAP2nQ4E/i+VjRGCpHK0KkpDH2meH8wWZfyns2nk7
oB2bAH9hrux1Lyt9VrLRXedFhBAu8FwAfqdcfMnmhdC/Be0dlGZblQ4PX2q5OP0a
npHQ9YzO7Q2U/I15Y4gVs1yjg47BQE840a0GefOrS8KG2fqWVDwq9fJJdJNSchVF
uGgrO+zaAVUzuwRvRfSN
=tQp1
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This looks more promising, though is still irrelevant to the issue of your
server side since it’s not the limited side:

http://www.cyberciti.biz/tips/linux-increase-outgoing-network-sockets-range.html

Good luck.

ab@novell.com wrote:
> Yes, that is likely the problem, but it is, as mentioned, still a client
> problem. The limit is on the number of OUTBOUND connections. Anyway, if
> you really want to do it Google for:
>
> /proc/sys/net/ipv4/ip_local_port_range
>
> The following came up for me as one runtime option, though its setting
> will not last across reboots. I have not found where to set the value
> permanently for persistence:
>
> http://docs.sun.com/source/817-2180-10/pt_chap6.html
>
> Good luck.
>
>
>
>
>
> uans wrote:
>> I did a search and here what I found:
>
>> User wrote:
>
>> I once wrote a server program, it prefer a long connection, I mean,
>> accept once then loop read/write, but if client only give once
>> read/write, it can close the client fd no problem. Then I wrote a client
>> a program but it prefer short connection, that is,
>> connect/write/read/close, then the client loop do connect/read/write
>> about 1 millioin times. I found after about 28231 connection, the client
>> exeception with error “Cannot assign requested address - connect(2)”. if
>> I change the client model to long connection, or I change the server
>> model to process only short connection, that is accept/read/write/close
>> the client fd, all is ok, what’s wrong? server and client code
>> attached.
>
>> Here was the reply:
>
>> The machine ran out of dynamic ports to assign as the source port for
>> the outbound connection. Either get the administrator of the machine to
>> allow a larger range of source ports or ‘bind’ to a random source port
>> chosen over a large range (say, 34000-60000) yourself.
>
>> My question is where can I inlarge the port size limit at?
>
>> THKS,
>> uans
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLPRhgAAoJEF+XTK08PnB5vTcQAIvK3j+AfrYaOLzRKph7kSE3
d2dpiscZh/FohQewDhcGkVEINtbrr7caRRo3dODG44OzKbW/9ifwcHn12cIDPhKo
kz/Yv2i3r7BvU+LpUa3P3hYBQmPYabtzPUHKnuQoUh0DGF+UyQVhAPnTM+cwNHEY
uoAMZY/Z1Ujqj9YGogII18BcRf0MeCU6PLBP0ygX4QR+U+IZ3JDdHuUl6uin+4r2
3UaM8sEDVP0W7fSpAN2ZaAtSI+qXYLDVVtgvex9C2R3JMQyM4YcQl9ZpCSkW5jNx
Ymmb/+7gLNc6XIlhi9pSgchqFHDYz42zfYDZxXlVyGLKHIysB8YPlJ+mQh7XwBUb
6j39VWh29pXEdfxR5CAothYuhbR71Mp6nlaQhvbwIl5IRI32W+XiE3ZOTJqaf/At
VkpuAI98UpDYDyP9TzO0ETrZiuL3h+elogw8xb4krbTOhva/jovi3+nBcr5lGxwm
kmxhssHxrIM5vUl/fpZ37qpRd26Haya7Rf2CIphNwMHWmAi2tdSMt+9BCDH8OBUg
xTtjUkx4+vhdxZPSAg1paT61sWDJShS9XorR6VaQxIP0l1foZdKeZTckb3W74xHU
y/7FBCZQzgu6jFoc3aiiHps7tkEOmVgOt9RPNI3RyW4Yg6XBlcEOvm5eAeSwk9cG
eJnsCfb1PXEAPEK4BKvY
=tQvo
-----END PGP SIGNATURE-----

That seemed to do it. My goal was 50k of client. The limitation is only net.ipv4.ip_local_port_range max. Just so you know, the server can handle 30k 0f burst client with 5k concurrent client connections without any interruption to the dispatching payload.

THKS,
uans

Last note, it was the client program on the server machine that was issuing the errno[99] not the server program on the server machine. This should make sense to you now.

I’m out,
uans