Re: FreeBSD 6.1 max sockets
On Fri, Oct 20, 2006 at 04:17:52PM +0800, ke han wrote: > Thanks for the reply. > This app is intended to keep 20,000++ sockets alive at a time. These > sockets are very long lived. > I understand about kqueue. I will eventually write for this. > What I need to understand are the various kernel tunings required to > handle 20,000++ active sockets. I would like to approach the > theoretical max...is it 64k? That is, is the absolute max socket > descriptors 64k? any thing else in the way of this maximum? I only have to say "Sorry, I don't know" for this question. :-) I hope other more experienced folks in this list will help you. I can give you just a thought however. If you have such massive requirements if I were you I would do the socket handling inside the kernel itself. That way you avoid the very expensive user space/kernel space context switch and also go in for some embedded system suited for this sort of thing. Perhaps I am talking rubbish. If so please pardon me. :-) Best of luck! regards, Girish ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: FreeBSD 6.1 max sockets
Thanks for the reply. This app is intended to keep 20,000++ sockets alive at a time. These sockets are very long lived. I understand about kqueue. I will eventually write for this. What I need to understand are the various kernel tunings required to handle 20,000++ active sockets. I would like to approach the theoretical max...is it 64k? That is, is the absolute max socket descriptors 64k? any thing else in the way of this maximum? thanks, ke han On Oct 20, 2006, at 4:05 PM, Girish Venkatachalam wrote: On Thu, Oct 19, 2006 at 11:24:30PM +0800, ke han wrote: I am writing a socket server deamon in C++ on FreeBSD 6.1 (or 6.2 if this matters to your answer). What this does is accept many sockets and does a little work with each. Each socket has low traffic but stay connected for long periods. All these sockets get accepted through one public ip:port (if this matters). So my desire is two things: 1 - good event handling for knowing which sockets have new data. I assume kqueue is the way to go here? 2 - I need to know what my limits are on max number of sockets. If my system is a 64-bit install on a server with 8GB RAM, I need to know how many sockets I can handle. Also, what options do I have to tune this? socket buffer size? Any kernel parameters needed to tune? As Chuck said select(2) is a good choice. That is what I used. kqueue() is more powerful and certainly much better when it comes to handling large number of sockets since kqueue(2) is very efficient when it comes to polling sockets for events. If you use select, the problem is that if you have say 2000 sockets and only one socket is available for read/write, then select has a stupid algo to figure out. Doesn't scale well. But kqueue(2) is very good at that sort of thing. Also kqueue() has a built in event mechanism that can be extended for signals and files also. If the sockets stay connected for long periods you may also want to enable TCP KEEPALIVE flag on the sockets. I don't think RAM and processor will be the bottleneck for you. Since in typical scenarios number of concurrent connected sockets don't usually hit such high limits. They come and go... HTH. Best of luck! regards, Girish ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions- [EMAIL PROTECTED]" ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: FreeBSD 6.1 max sockets
On Thu, Oct 19, 2006 at 11:24:30PM +0800, ke han wrote: > I am writing a socket server deamon in C++ on FreeBSD 6.1 (or 6.2 if > this matters to your answer). What this does is accept many sockets > and does a little work with each. Each socket has low traffic but > stay connected for long periods. All these sockets get accepted > through one public ip:port (if this matters). > So my desire is two things: > 1 - good event handling for knowing which sockets have new data. I > assume kqueue is the way to go here? > 2 - I need to know what my limits are on max number of sockets. If > my system is a 64-bit install on a server with 8GB RAM, I need to > know how many sockets I can handle. Also, what options do I have to > tune this? socket buffer size? Any kernel parameters needed to tune? > As Chuck said select(2) is a good choice. That is what I used. kqueue() is more powerful and certainly much better when it comes to handling large number of sockets since kqueue(2) is very efficient when it comes to polling sockets for events. If you use select, the problem is that if you have say 2000 sockets and only one socket is available for read/write, then select has a stupid algo to figure out. Doesn't scale well. But kqueue(2) is very good at that sort of thing. Also kqueue() has a built in event mechanism that can be extended for signals and files also. If the sockets stay connected for long periods you may also want to enable TCP KEEPALIVE flag on the sockets. I don't think RAM and processor will be the bottleneck for you. Since in typical scenarios number of concurrent connected sockets don't usually hit such high limits. They come and go... HTH. Best of luck! regards, Girish ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: FreeBSD 6.1 max sockets
On Oct 19, 2006, at 8:24 AM, ke han wrote: So my desire is two things: 1 - good event handling for knowing which sockets have new data. I assume kqueue is the way to go here? kqueue would be a fine choice, otherwise the typical mechanism involves using select(). 2 - I need to know what my limits are on max number of sockets. If my system is a 64-bit install on a server with 8GB RAM, I need to know how many sockets I can handle. Also, what options do I have to tune this? socket buffer size? Any kernel parameters needed to tune? See the sysctl kern.ipc.maxsockets. You can change this and related settings by adjusting loader.conf (see /boot/defaults/loader.conf and "man tuning" about "LOADER TUNABLES")... -- -Chuck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"