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
However during the process of adding new songs itunes crashed and i had to end task therefor not getting the chance to sync the new songs onto ipod nano. later when i plugged in my current ipod touch all my songs have disappeared and i cant find the [More]
Hi, I´m new working with liveCycle, and I would like to know how it works at technical level. I have read documentation but I can not understand the procedure to generate the digital signature I appreciate someone explain a bit about it or send a lin [More]
Hello all. I recently replaced the HD in my MacBook Pro. Just after, I retrieved my old files from the Time Machine backup, which I made just before the replacement. During the first sync of my iPhone via iTunes and while I was trying to sync my cont [More]
I plug in my ipod and itunes immediately freezes (program not responding) I have checked using my 4th Generation ipod that it's software is up to date (running 6.1.6) and have done the same with itunes (11.3) Thoughts?iTunes for Windows XP: Troublesh [More]
Hi, I need to call a VBS program from an abap program.  This abap will run on both 4.6 and 4.0. I would be very grateful for any suggestions on how this can be done. Thanks and Kindest Regards Danielledata: commandline(1000). commandline = v_vbs_file [More]
I tried to sync my iphone and it wouldnt bring up itunes..tried to manually open itunes and get this error The procedure entry point kFigMetadataFormat_QuicktimeMetadata could not be located in the dynamic link library Media Toolbox.dll. then get itu [More]
We have come across a problem using Adobe Photoshop CS6 and Illustrator CS6 on a MAC. We use Illustrator CS6 for putting together the graphics and use Photoshop CS6 for editing. When we save the image in full res and browse the image - the image look [More]
Hi friends, Greetings. I am a beginner in Java. I am doing an exercise using jdbc:odbc driver where i have to query the database in one function and pass the ResultSet to another function. Let function1 be ResultSet select(String sel) // sel is the i [More]
Not really a problem as I don't usually use my G4 eMac but I don't like it when things suddenly lose functionality. A couple of months ago I updated from OS X 10.4.10 to 10.4.11 and I have noticed recently that FCP 5.1 no longer opens. I also tried t [More]
For the last two weeks my connection has been dropping After four phonecalls and over 3 hours on the phone in que's it is still happening and I'm so close to just cancelling the direct debit and telling BT to stick it. What the hell is going on with [More]