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 want to update my phone cause these popups keep annoying me but I'll press agree and it won't do anything it doesn't freeze but it just won't work so I'll go to apple support and I want them to email me but my email isn't on my phone so I'll go to [More]
I have a component which I want to re-use in applications. The component should have 2 outbound (interface) plugs which can be wired into parent applications. When the user clicks buttonA in the component it should fire outboundPlugA, likewise for bu [More]
Having installed Photoshop Elements 11(Windows 7)  I cannot open the Organiser from the welcome screen. It can be opened via the Editor but few of the thumbnails are shown as pictures rather as empty squares. The situation does not improve with time [More]
When setting view options for a finder window set to list view, I cannot get column resizing or positioning to hold. When making those changes, the option for "All Windows" automatically shifts to "This window only" and it then does no [More]
Hello All, JUST AN FYI... More bars... in more places? Yes. But... Make sure you are checking your dBm signal strength. I did the 2.1 upgrade and my son did not. I had 1 more bar than he did on the way to school. We usually have 4 bars, but after the [More]
Hello I have a problem connecting to shares on at NSS4000 with windows 2008 server and windows 7 below is the CIPS log fil. Do anyone have some suggestions? Apr 4 14:33:56 LILLYNAS nmbd[4513]: [2012/04/04 14:33:56, 0] nmbd/nmbd.c:main(711) Apr 4 14:3 [More]
Hi Has anyone seen this error before? Environment Configuration: APP SERVER 9.0.4 (OUT 0F BOX CONFIG) JDK 1.4 RED HAT ENTERPRISE SERVER 3.0 COMPAC DL380 ON VM SOFTWARE DB 9.2.0.4 HP-UX 11i SUPERDOME Error logs: [18-06-04 10:27:20] [AJPRequestHandler- [More]
Hi,      i had a query about local storage.      I've a machine that hosts weblogic and tangosol. i've an ejb that accesses a distributed cache i.e NamedCache cache = CacheFactory.get("MyCache")      i modified tangosol-coherence.xml and set loc [More]
A few days ago I had a keychain failure and since then Mail and the system periodically ask me to enter the keychain password. I'd like to stop this behavior and let all installed apps use keychain while I'm logged in. Where do I find the setting?Pul [More]
I found the answer: Sweetpacks New Tab for FireFox 1. In the address bar, type 'about:config' and then click Enter. 2. You will be notified that you are about to change your settings. Click 'I'll be careful, I promise!' 3. You will see a Search field [More]