Sitemap

Amicuk Programming Answers

How can I have my servlet accept 100 concurrent client requests?

-0001-11-30   Views:0

Advertisement

          My servlet extends HttpServlet so it is multithreaded. Then I have written a java           client which starts 100 concurrent threads that try to contact the servlet.           There are always lots of threads which are refused by the Webl

          My servlet extends HttpServlet so it is multithreaded. Then I have written a java
          client which starts 100 concurrent threads that try to contact the servlet.
          There are always lots of threads which are refused by the Weblogic Server 6.0.
          They get a 'Connection refused' exception. Sometimes there are 50 refused connections,
          sometimes there are 0 refused connections (not very often), sometimes there are
          80 refused connections (usually).
          I have checked the 'Servlet' documentation and the 'J2EE Design Considerations
          for Weblogic Server' which recommends not to exceede the execute thread count
          number of 15. I have not changed that value, I do not even know if it still exists
          in Weblogic 6.0 as the document refers to the 5.0 version.
          Does anybody know how to solve this problem? How can I have the client requests
          waiting rather than being refused? Of course the main goal is to serve all the
          client requests, not to refuse.
          This is the code that the client thread uses to contact the servlet:
          URL url = new URL("http://localhost:7001/examplesWebApp/myServlet");
          URLConnection conn = url.openConnection();
          conn.setDoInput(true);
          conn.setDoOutput(true);
          DataOutputStream os = new DataOutputStream(conn.getOutputStream());
          os.writeBytes()
          os.writeBytes()
          Thanks for your time,
          David
          

The replay answer
Advertisement
          The key is
          KKEY_LOCALMACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters
          There you may need add a value "MaxUserPort" as REG_DWORD (5000 is default), also
          change "TcpTimedWaitDelay" to small number (30 is minimum). You may have trouble
          to find them. Just add them.
          You can also use Microsoft Web Application Stress Tool to test your Weblogic applications.
          As a free test tool, it is really powerful, although not so flexible.
          I guess you write your own test tool with java.net.URLConnection. I am not sure
          about the power of this class. In my case, I wrote my stress test tools with Java
          Socket. I can test application on Weblogic 6 with 1000 threads with my own tool
          and Microsoft tool, depending on memory and CPU of the machines I use. I run my
          tests on both Windows 2000 professional and Solaris.
          Check your CPU and memory usage with task manager.
          On the other hand, you should check log message on Weblogic 6. Try to turn on
          HTTP debug by add the following in your config.xml in tag <Server>.
          <ServerDebug DebugHttp="true" DebugURLResolution="true"
          JDBCConn="true" JDBCSQL="true" ListenThreadDebug="true" Name="myserver"/>
          "David Ruana" <[email protected]> wrote:
          >
          >Xiang, I really appreciate your help. I changed my Weblogic server configuration
          >from the console but I still experience the same problems.
          >
          >I start my 100 threads, and from about the 20th onward all them get the
          >'Connection
          >refused' exception in the URLConnection::getOutputStream() function,
          >always after
          >a successful URLConnection::openConnetion().
          >
          >My system is Windows 2000 Professional (Spanish version). I tried to
          >check the
          >open client socket descriptor limit but I was not able to find the TCPIP/MAXUSERPORT
          >in the registry. Do you know how is this entry called in Windows 2000?
          >
          >At this point I am not sure whether my problems are related to the Weblogic
          >server
          >or to the operative system. I will keep trying... I would appreciate
          >any other
          >suggestion.
          >
          >Thank you very much.
          >
          >
          >
          >"Xiang Rao" <[email protected]> wrote:
          >>
          >>It is better to use Weblogic 6 console to configure Weblogic server.
          >>In the console,
          >>there is tab Servers->myServer->Congiguration->Tuning, you can find
          >execute
          >>length
          >>and backlog.
          >>
          >>If you use Windows as test client, note Windows have a 5000 open client
          >>socket
          >>descriptors limit. You need change Windows Registry (TCPIP/MAXUSERPORT)
          >>to change
          >>this parameter.
          >>
          >>On the other hand, during test, you should monitor your test via Weblogic
          >>console
          >>(myServer->Monitoring->Performance), here you can see the change of
          >wait
          >>queue.
          >>If the queue keeps increaing, you are in trouble.
          >>
          >>Since you know how to use MBean, try to write customized (servlet, for
          >>example)
          >>to collect the following data: opened socket number, open socket number,
          >>opened
          >>session number and open session number. The two "open" numbers will
          >give
          >>you some
          >>clue. Also record your CPU and memory usage.
          >>
          >>BTW, what is the output you get from your test in terms of number of
          >>requests
          >>per second, response time and number of bytes downloaded/uplodaed per
          >>second?
          >>Are your test client and Weblogic running on the same machine?
          >>
          >>
          >>
          >>"David Ruana" <[email protected]> wrote:
          >>>
          >>>By the way, this is a piece of the config.xml file where you can see
          >>>my Server
          >>>configuration. It is the configuration which is installed in the examplesServer
          >>>in the free evaluation of Weblogic 6.0. I only modified the AcceptBacklog
          >>>value,
          >>>and added the ThreadPoolSize="15" line which was missing (I copied
          >from
          >>>the petstoreServer).
          >>>
          >>> <Server AcceptBacklog="1000" AdministrationPort="0" ClusterWeight="1"
          >>> ConsoleInputEnabled="false" DGCIdlePeriodsUntilTimeout="2"
          >>> DefaultProtocol="t3" DefaultSecureProtocol="t3s"
          >>> HttpdEnabled="true" JavaCompiler="C:\bea\jdk130/bin/javac"
          >>> ListenPort="7001" Name="examplesServer" NativeIOEnabled="true"
          >>>     ThreadPoolSize="15"
          >>> SocketReaderTimeoutMaxMillis="10"
          >>> TransactionLogFilePrefix="config/examples/logs/"
          >>> TunnelingClientPingSecs="45" TunnelingClientTimeoutSecs="40"
          >>>XMLRegistry="examplesXMLRegistry">
          >>> <ServerDebug Name="examplesServer"/>
          >>> <WebServer DefaultWebApp="DefaultWebApp_examplesServer"
          >>> LogFileName="./config/examples/logs/access.log"
          >>> LoggingEnabled="true" Name="examplesServer"/>
          >>> <Log FileName="./config/examples/logs/weblogic.log" Name="examplesServer"/>
          >>> <KernelDebug Name="examplesServer"/>
          >>> <SSL Enabled="true" ListenPort="7002" Name="examplesServer"
          >>> PeerValidationEnforced="0"
          >>> ServerCertificateChainFileName="./config/examples/ca.pem"
          >>> ServerCertificateFileName="./config/examples/democert.pem"
          >>> ServerKeyFileName="./config/examples/demokey.pem" TrustedCAFileName="./config/examples/ca.pem"/>
          >>> </Server>
          >>>
          >>>
          >>>
          >>>
          >>>
          >>>"Xiang Rao" <[email protected]> wrote:
          >>>>
          >>>>You only need to change Weblogic HTTP configuration. Give the server
          >>>>a big socket
          >>>>Backlog number. Since you test with 100 threads, you can think 1000
          >>>to
          >>>>5000, i.e.,
          >>>>1000 to 5000 requests will be in queue before got served. Aslo, you
          >>>might
          >>>>need
          >>>>to change your OS TCP/IP settings (both test clients and servers),
          >>such
          >>>>as maximum
          >>>>number of sockets and timeout value(so closed sockets will release
          >>socket
          >>>>descriptors
          >>>>immediately).
          >>>>
          >>>>On the other hand, the number of executive threads can be much larger
          >>>>than 15
          >>>>(50-200 is a normal number), depending on the features of your application.
          >>>>You
          >>>>can try your stress test tools to find a reasonable number by analyzing
          >>>>the relationships
          >>>>among (throughtput, response time, number of executive threads, etc).
          >>>>
          >>>>
          >>>>"David Ruana" <[email protected]> wrote:
          >>>>>
          >>>>>My servlet extends HttpServlet so it is multithreaded. Then I have
          >>>written
          >>>>>a java
          >>>>>client which starts 100 concurrent threads that try to contact the
          >>>servlet.
          >>>>>
          >>>>>There are always lots of threads which are refused by the Weblogic
          >>>Server
          >>>>>6.0.
          >>>>>They get a 'Connection refused' exception. Sometimes there are 50
          >>refused
          >>>>>connections,
          >>>>>sometimes there are 0 refused connections (not very often), sometimes
          >>>>>there are
          >>>>>80 refused connections (usually).
          >>>>>
          >>>>>I have checked the 'Servlet' documentation and the 'J2EE Design Considerations
          >>>>>for Weblogic Server' which recommends not to exceede the execute
          >thread
          >>>>>count
          >>>>>number of 15. I have not changed that value, I do not even know if
          >>>it
          >>>>>still exists
          >>>>>in Weblogic 6.0 as the document refers to the 5.0 version.
          >>>>>
          >>>>>Does anybody know how to solve this problem? How can I have the client
          >>>>>requests
          >>>>>waiting rather than being refused? Of course the main goal is to
          >serve
          >>>>>all the
          >>>>>client requests, not to refuse.
          >>>>>
          >>>>>This is the code that the client thread uses to contact the servlet:
          >>>>>
          >>>>>URL url = new URL("http://localhost:7001/examplesWebApp/myServlet");
          >>>>>URLConnection conn = url.openConnection();
          >>>>>conn.setDoInput(true);
          >>>>>conn.setDoOutput(true);
          >>>>>
          >>>>>DataOutputStream os = new DataOutputStream(conn.getOutputStream());
          >>>>>os.writeBytes()
          >>>>>os.writeBytes()
          >>>>>...
          >>>>>
          >>>>>Thanks for your time,
          >>>>>David
          >>>>>
          >>>>
          >>>
          >>
          >
          

Go to See the other 7 answers

How can I have my servlet accept 100 concurrent client requests?

Category:DefaultRelease time:-0001-11-30Views:130

          My servlet extends HttpServlet so it is multithreaded. Then I have written a java           client which starts 100 concurrent threads that try to contact the servlet.           There are always lots of threads which are refused by the Webl[More]

When a servlet accepts a call from a client, it receives two objects.what??

Category:DefaultRelease time:-0001-11-30Views:130

hi, When a servlet accepts a call from a client, it receives two objects. What are they???How will u pass the argument from one servlet to another servlet??Actually, it's dead simple: Just tell servlet #1 that servlet #2 said something nasty about se[More]

ITunes accepted my de-authorize request but didn't reset. Now when I check it it says I have to wait till June 26th? There has to b a way to reset this! I can't wait to access my Cloud svcs etc for 2 months!

Category:DefaultRelease time:-0001-11-30Views:130

iTunes accepted my de-authorize request but didn't reset. Now when I check it it says I have to wait till June 26th? There has to b a way to reset this! I can't wait to access my Cloud svcs etc for 2 months!That means you had already done de-authoriz[More]

How to activate / disactivate a servlet with a java client ?

Category:DefaultRelease time:-0001-11-30Views:130

I would like to know how to activate or disactivate a servlet with a java client or an applet ? Thanks...What does "activate" mean for servlets?Read other 2 answers[More]

Servlets handle multiple, concurrent requests

Category:DefaultRelease time:-0001-11-30Views:130

Hi, folks. Could someone give me a basic idea of how Servlets handle multiple, concurrent requests which are sent from user's web browser, or possibly, point me some useful web links, tutorials. Let me take a example to make sure that i have explaine[More]

Can a servlet do something without a request from a client?

Category:DefaultRelease time:-0001-11-30Views:130

Hi, is a servlet only invoked when a client calls doGet() or doPost() or is there a way to let the servlet do something while it is idle. Maybe with a thread? Can a servlet start a thread that will work forever? And do servers usually close servlets[More]

Sun App Server 9 not accepting HTTP/0.9 requests

Category:DefaultRelease time:-0001-11-30Views:130

I'm trying to set up the application server to accept HTTP/0.9 requests. I've tried changing the HTTP Protocol version from HTTP/1.1 to HTTP/0.9 but it doesn't seem to do anything. I'm running Sun Java System Application Server Platform Edition 9.0_0[More]

Accepting connection from client

Category:DefaultRelease time:-0001-11-30Views:130

Hello, I want to create java server which accepts connection from client once and then continuously waits for request sent by client. Something same as select() call in C Something of kind Server.java: Socket socket = server.accept(); while(true) //[More]

50-100 concurrent users

Category:DefaultRelease time:-0001-11-30Views:130

Hi..I would like to know what is the optimum number of weblogic server to support 50-100 concurrent users. Is there anywhere that I can get some benchmarking?It depends on the complexity of your application. In my experience for sub second responses[More]

Iteratively accept client requests

Category:DefaultRelease time:-0001-11-30Views:130

Hi, My server has to accept client requests iteratively. Below are my codes. However, I find that a request is processed twice and after which error of file not file which is somewhere else of my codes is printed non stop. Not sure is it due to the l[More]

100 concurrent calls

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I was thinking about 100 concurrent calls and I have used TAC bandwidth computation for this. Based on the computation I need to have a T1 link. What if I can't afford to get a T1 link and atmost I can only get a 512kbps. Will it still support 10[More]

Hot
I really appreciate the detail that wjosten provides on the User Tip entitled "Syncing to a New Computer or Replacing a crashed hard drive".  I do have a follow up question though about my wife's iPhone 4 running iOS 5.1.1.  All her calendar and [More]
I have Mac OS 10.5 Leopard installed on 4 computers in a Home Network and have a problem with sharing files and using screen sharing. Here is my setup. MacBook Pro with my logon ID MacBook Pro with my fiancee's logon ID Mac Mini with both of our logo [More]
Hi. I want to  wipe the entire phone clean. Not just apps and memory but "clean". As in nothing. Nadda. poof. I want to brick it. I have an issue and I need to try and start from the very beginning.Dowload the OS you want to put on to it and ins [More]
Hello, Im interested how to create the *.xls file with NI Library. I cant find the right function. Usually, Im using following code (ODBC): CDatabase database;   CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)"; // exactly the same name as in [More]
Hi... I am currently dealing with the RTPPlayerApplet that is embedded in a web page... However, i have the following errors when viewing the page... [Thu Jul 07 11:03:39 2005] [error] [client 127.0.0.1] File does not exist: C:/Apache-2.0.05/Apache2/ [More]
I have a Shuffle that will play just fine in the "play in order" position, but when I switch to the "shuffle songs" position, nothing happens (no light, no sound). I tried restoring it, but I got the same results. Does anyone have any [More]
Will a backup made with iPhoto 6 work or read on 1 photo8? Thanks Everett E. Brust <edited by host - please, for your own protection, do not put personal contact information in posts>brustee: If the disk was burned via iPhoto's Share->Burn Disk m [More]
I am struggling to find clear guidance on how to switch on colour management in Flash CS4. My attempts to search online have tended to give me far too many irrelevent results and it is not even mentioned in the index of my 700 page Flash CS4 textbook [More]
I recently switched laptops (XP to Win7) and now I'm receiving the InDesign Content Manager error message. I'm running CS3 and the InDesign file is CS3, as well. I also ran the plug-in and software update, but I'm still unable to open any InDesign fi [More]
Hi, I am trying to configure DMVPN in my lab. It shows unrecognised command when I try "ip nhrp".  I am using Adv IP services 15.2 IOS image. I even tried this with Adv Enterprise k9 IOS image but it doesn't seem to work. Can someone please guid [More]