Re: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients.
Hello Erich, I see in your other mail that your problem is solved. So here I try to answer to your additional questions. > What influences how much buffer RAM is used by each socket. It is the socket itself and also the data. A socket takes around 4 KB. Overlapped IO takes also pages of 4 KB but in case of lot's of data it can be more. Nothing to tell how mutch more exacly in case of mutch hi speed data. In normal circumstances you can say that a socket wich is sending and receiving will take 12 KB. > Also, what is the relevance of OnBgException? OnBgException is fired when there is an exception from the middle of nowhere, that is from the message pump. If it happens then normally it will come from your code, eg an unhandled exception in some of the events. Just in case it is safe to have an event handler in it, I do always to be safe. Just put CanClose to True. Socket will close, and you you can in the OnSessionClosed handler post a message to custom message handler to re-listen, or to re-connect. > Do I need to bind to it on my listening socket or my working socket? Both of them, see above. > processed. Also, you talk about 1/8 of system RAM being able to be used for > this buffer RAM. Is that for all applications, or is that per application. For all applications on the machine including NT services. All overlapped IO uses non pageable RAM. Also it is not only 1/8 of system RAM, it is also harware limited. But don't know the hardware limit from the top of my head. --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients.
Hi Edward, Seeing as you raised this issue, and I have been experiencing the same thing, I thought I'd dedicate the day to trying to understand what is happening, and the good news is that I've managed to solve my problems, and gained a valuable understanding of the problem. Here's the thing. As a developer, you always suspect your code first don't you. Well, in my case, and maybe in yours, it's not the code. I did several tests on two Windows 2003 servers (2xQuad core, 4GB RAM, Win2003 Std Server) (one as a client and one as a server) and a Linux Server as a client, and the results were totally unexpected. I managed to get the same thing to happen, (server stopped listening), but here's the thing, it didn't really stop listening ... I could still connect a socket to the port via telnet from the Linux server, but not from the windows server. So that got me goggling ... Windows has some interesting registry settings which limit the number of OUTBOUND connections. Yip ... the outbound socket from my stress testing app was the problem, not the listening socket in the server application. Of course your server application may also have outbound sockets, as mine does, and that would simply exaggerate the problem. Anyway, this is best described in http://www.redbooks.ibm.com/redpapers/pdfs/redp3943.pdf Just look at the section under TCP TIME-WAIT Delay. Basically it says that the default Windows 2003 Server install limits the number of outbound sockets to 5000, and the TIME-WAIT to 120 seconds (That means that after a disconnect, Windows does not reuse that socket number for 120 seconds). Now, in my case I was exceeding this, and you may well be too. The good news is that you can crank these numbers up quite a bit. The number of sockets can go up to 65534, and the TIME-WAIT can come down to a few seconds if you wish with a recommendation of 30 seconds. Anyway, I'm glad that this is resolved from my perspective anyway. I hope that it works for you. Remember that you have to reboot the server before the changes will take effect. Cheers Erich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Edward Koo Sent: Thursday, 13 September 2007 3:33 p.m. To: twsocket@elists.org; [EMAIL PROTECTED] Subject: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients. Hi Wilfried, thank you for replying. How do i check how much non pageable ram is available? The test i did for Windows Server 2003 runs on a system with Xeon processor and 3gb ram. It consistently stop at 180-200 concurrent clients which is very strange compared to the other test that accepts 500-600 concurrent clients on Windows XP with single core processor and only 512mb ram. The difference i notice on the Windows Server 2003 test were that the data being received is a lot faster which makes me suspect that the main thread that listen to clients are too busy pushing data to clients and after a while the listening were timed out or something like that? Btw, after i diconnect all client i have check with netstat -n -p tcp a few times and there's no socket in WAIT_STATE at port 2 which is the port the server use and still the problem persist. It just won't accept client anymore even Netstat -a shows the server in listening state. See the following, C:\Documents and Settings\edwardkoo>netstat -a Active Connections Proto Local Address Foreign Address State TCPEdward:httpEdward.N2NMSC.COM:0 LISTENING TCPEdward:epmap Edward.N2NMSC.COM:0 LISTENING TCPEdward:microsoft-dsEdward.N2NMSC.COM:0 LISTENING TCPEdward:gds_db Edward.N2NMSC.COM:0 LISTENING TCPEdward:3389Edward.N2NMSC.COM:0 LISTENING TCPEdward:2 Edward.N2NMSC.COM:0 LISTENING TCPEdward:58581 Edward.N2NMSC.COM:0 LISTENING TCPEdward:1059Edward.N2NMSC.COM:0 LISTENING C:\Documents and Settings\edwardkoo>netstat -n -p tcp Active Connections Proto Local Address Foreign Address State TCP127.0.0.1:1089 127.0.0.1:1090 ESTABLISHED TCP127.0.0.1:1090 127.0.0.1:1089 ESTABLISHED TCP127.0.0.1:1091 127.0.0.1:1092 ESTABLISHED TCP127.0.0.1:1092 127.0.0.1:1091 ESTABLISHED TCP127.0.0.1:1276 127.0.0.1:9000 ESTABLISHED TCP127.0.0.1:9000 127.0.0.1:1276 ESTABLISHED TCP192.168.0.136:1106 202.75.55.43:2888 ESTABLISHED TCP192.168.0.136:1275 192.168.0.136:3050 ESTABLISHED TCP192.168.0.136:1304 192.168.0.11:135 TIME_WAIT TCP192.168.0.136:1305 192.168.0.11:1026 TIME_WAIT TCP192.168.0.136:3050 192.168.0.136:1275 ESTABLISHED I made a button that will close the listening socket and re-listen so when the problem occurs i click the button to test. After i click the button the listening will work for a while and then it will eventually stop again. I already tried catching OnB
Re: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients.
Have you tried with one of the server demos included with ICS ? Just to see if it is related to your code or elsewhere. It is also possible that windows run out of other kind of resource. Have you "instrumented" your program with - for example - FastMM which could tell you about memory leaks ? Another possibility is that you are wrongly handling some exception for example by simply shutting the exception down with en empty except block in a try/except. -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be - Original Message - From: "Edward Koo" <[EMAIL PROTECTED]> To: ; <[EMAIL PROTECTED]> Sent: Thursday, September 13, 2007 5:33 AM Subject: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients. > Hi Wilfried, thank you for replying. > > How do i check how much non pageable ram is available? > The test i did for Windows Server 2003 runs on a > system with Xeon processor and 3gb ram. It > consistently stop at 180-200 concurrent clients which > is very strange compared to the other test that > accepts 500-600 concurrent clients on Windows XP with > single core processor and only 512mb ram. > > The difference i notice on the Windows Server 2003 > test were that the data being received is a lot faster > which makes me suspect that the main thread that > listen to clients are too busy pushing data to clients > and after a while the listening were timed out or > something like that? > > Btw, after i diconnect all client i have check with > netstat -n -p tcp a few times and there's no socket in > WAIT_STATE at port 2 which is the port the server > use and still the problem persist. It just won't > accept client anymore even Netstat -a shows the server > in listening state. See the following, > > C:\Documents and Settings\edwardkoo>netstat -a > > Active Connections > > Proto Local Address Foreign Address > State > TCPEdward:httpEdward.N2NMSC.COM:0 > LISTENING > TCPEdward:epmap Edward.N2NMSC.COM:0 > LISTENING > TCPEdward:microsoft-dsEdward.N2NMSC.COM:0 > LISTENING > TCPEdward:gds_db Edward.N2NMSC.COM:0 > LISTENING > TCPEdward:3389Edward.N2NMSC.COM:0 > LISTENING > TCPEdward:2 Edward.N2NMSC.COM:0 > LISTENING > TCPEdward:58581 Edward.N2NMSC.COM:0 > LISTENING > TCPEdward:1059Edward.N2NMSC.COM:0 > LISTENING > > > C:\Documents and Settings\edwardkoo>netstat -n -p tcp > > Active Connections > > Proto Local Address Foreign Address > State > TCP127.0.0.1:1089 127.0.0.1:1090 > ESTABLISHED > TCP127.0.0.1:1090 127.0.0.1:1089 > ESTABLISHED > TCP127.0.0.1:1091 127.0.0.1:1092 > ESTABLISHED > TCP127.0.0.1:1092 127.0.0.1:1091 > ESTABLISHED > TCP127.0.0.1:1276 127.0.0.1:9000 > ESTABLISHED > TCP127.0.0.1:9000 127.0.0.1:1276 > ESTABLISHED > TCP192.168.0.136:1106 202.75.55.43:2888 > ESTABLISHED > TCP192.168.0.136:1275 192.168.0.136:3050 > ESTABLISHED > TCP192.168.0.136:1304 192.168.0.11:135 > TIME_WAIT > TCP192.168.0.136:1305 192.168.0.11:1026 > TIME_WAIT > TCP192.168.0.136:3050 192.168.0.136:1275 > ESTABLISHED > > > I made a button that will close the listening socket > and re-listen so when the problem occurs i click the > button to test. After i click the button the listening > will work for a while and then it will eventually stop > again. > > I already tried catching OnBgException but it does not > trigger even though the problem occurs. > > > > > > Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. > http://answers.yahoo.com/dir/?link=list&sid=396545433 > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients.
Hi Wilfred, Please can you explain this a bit more. I also have this problem, and have actually had to resort to changing my system design just to get it working acceptably. What influences how much buffer RAM is used by each socket. Is it data through the socket? Also, what is the relevance of OnBgException? I'm not binding to it. Do I need to bind to it on my listening socket or my working socket? The listening socket passes the request to a working socket to be processed. Also, you talk about 1/8 of system RAM being able to be used for this buffer RAM. Is that for all applications, or is that per application. I was really surprised when I hit this problem. I would like to move back to our original design, as we are concerned that the modified design is not that scalable. Any help that you or anyone else can offer in this regard would be much appreciated. Regards Erich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Wilfried Mestdagh Sent: Wednesday, 12 September 2007 11:08 p.m. To: ICS support mailing Subject: Re: [twsocket] TWSocket Stop Listening After Certain Numbers ofConnected Clients. Hello Edward, Possible you ran out of buffer space. Winsock use non pageble ram. The non pageable ram can grow to max 1/8 the size of total ram. Depending on traffic each socket need about 6 KB of it. And lots of other applications uses that part of RAM also (all overlapped IO for example). After all clients are disconnected you possible have all sockets still in WAIT_STATE. That can be the reason. Also be sure you hvae code in OnBgException and set CanClose to true. In OnSessionClosd you can post a message to a custom message handler to listen again. --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Wednesday, September 12, 2007, 07:05, Edward Koo wrote: > Hi, > I wrote a server with TWSocket that receive high speed > data and then push the data to connected clients. I > did some stress test recently and found that the > server will stop accepting client after it reach > something like 500-600 concurrent clients on Windows > XP and only about 180-200 on Windows Server 2003!? > Any client attempts to connect at this point will get > a socket error 10061, this happen even if all the > previous clients are disconnected. A breakpoint to the > code shows that SocketSessionAvailable will not > trigger anymore. It's like the server listening socket > is closed but I checked with Netstat -a and it shows > that the server is still listening to the designated > port. > I tried to change WSocket_listen backlog to 200 but it > won't help also. Any idea? > > Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. > http://mobile.yahoo.com/go?refer=1GNXIC -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be