RE: Struts and synchronization (Off Topic)
I don't this this is struts related. Unless you have a lot of synchronized code called by your execute method, it sounds more like a Tomcat/Apache issue. If you do have a bunch of code in your execute method that needs to be synchronized you have most likely shot yourself in the foot and should seek medical attention promptly. One of my first attempts at a J2EE application was very much hampered by an over-zealous attempt to create my own pooling mechanism which had a number of flaws that required very serious surgery to function properly. off-topic In regards to your configuration, it sounds like you are using (at least) two physical tiers for your web/app-server configuration. By this, I mean you have 1 set of machines for the web server portion, and another set for the servlet portion (I'm omitting everything else right now). You want to check on your servlet machine in the conf/server.xml and ensure you have enough request processors for whatever load you are throwing at the machine. Most connectors have a minProcessors and a maxProcessors as well as an acceptCount setting among other things. Make sure they are set appropriately high. If you have long running servlet on a fat machine, bump your acceptCount down and your min/max processors up. This will cause the servlet engine to do more concurrent work instead of queueing up network requests. There are some configuration settings on the web server side set in worker.properties that can also be tweaked. The most important (probably) of these would be if you are load balancing one web server to multiple servlet engines. Finally, if you have a lot of large/static content on every request, put it on the web server for high load. /off-topic -Original Message- From: Micael [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 8:20 PM To: Struts Users Mailing List; Struts Users Mailing List; Struts Users Mailing List Subject: Re: Struts and synchronization This will also, of course, lead to better performance, period, in your case. Sounds to me like you need something like a WorkerQueue where you put requests in a regular queque and a thread pool of anonymous worker threads run a FIFO collection. This is fairly standard stuff with Doug Lea's stuff on concurrent programming (try oswego doug lea in google). If you are single threaded, you will not be able to consistent. And, if you are multi-threaded, in the model, then there are numerous things you can do, even if the WorkerPool (or whatever Doug calls it, I forget) is but one thread. You an return the thread while the database is doing its stuff. Why not? There are a lot of creative solutions, once you use concurrent techniques. I hope this is helpful. If you don't need to return the results of the database, but just to update, then you can really make it hum, having the database stuff just in queque until the right time. I do this with helper computers doing little tasks for me on modem based home computers (with the consent of friends). I just have them pass a notice of what there ip address is to a queque with a time, and when I need a little work done, I pass it via a tunnel to the freshest ip address, which is held at the application level. Of course, it is even easier with static ips. But, my friends, like me, don't have static ips. We are POOR! LOL. Micael At 04:54 PM 8/11/2003 -0700, Micael wrote: Have you thought about using a multi-threaded solution with a queque such that when your database is busy you can notify the user that things are being processed and giving them a link to check back on? At 12:46 PM 8/11/2003 0500, Nathan Rogers wrote: The request path for a standard action within my code goes something like this : Struts servlet - action - model - database - model - action - Velocity servlet Here's what I know about each issue you've brought up. #1 - Tomcat is configured to work with the Warp connector. I don't know exactly how this works (if it passes all requests to Tomcat or just the ones registered to a servlet) #2 - I'll have to check with the sysadmin. Where is the number of request processors defined? #3 - I'm using the Jakarta Commons PoolingDataSource. I have used this before without any problems #4 - Something to look into. I'm closing my result sets, statements and connections (which returns them to the pool), but it might not be done in the best way. Mainguy, Mike wrote: The closest I ever came to this sort of problem involved the following: #1 Sending static content (and lots of it) through the servlet engine instead of using the web server. #2 Not having enough request processors and listeners configured. #3 Not using pooling for my connections and killing the DBMS with new connection requests. #4 Not properly closing/releasing my DBMS connections and consuming all available memory. So there you go, everything you should NOT do in a nutshell. Unless you're 100% proof-positive sure
Re: Struts and synchronization
At 10:50 AM 8/12/2003 +0100, you wrote: I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). To be honest, I'd give JDK 1.4.2 a try. We had a situation in Expresso where if you repeated a reload on a DBMaint jsp pages, it would eventually lock consuming 100% CPU and sucking up memory. Turned out that turning off Hotspot optimization [-Xint] with JDK 1.4.1 worked then I tried 1.4.2, and things worked great.. [For the record, if I took out a double-nested logic:iterate tag on the page, everything worked great. I suspect that hotspot saw it as an inner loop and 'overoptimized' so to speak] It might be or might not be the solution, but given my experience with 1.4.1, I'd at least eliminate that as a possibility. HTH! -Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
Have you thought about using a multi-threaded solution with a queque such that when your database is busy you can notify the user that things are being processed and giving them a link to check back on? At 12:46 PM 8/11/2003 -0500, Nathan Rogers wrote: The request path for a standard action within my code goes something like this : Struts servlet - action - model - database - model - action - Velocity servlet Here's what I know about each issue you've brought up. #1 - Tomcat is configured to work with the Warp connector. I don't know exactly how this works (if it passes all requests to Tomcat or just the ones registered to a servlet) #2 - I'll have to check with the sysadmin. Where is the number of request processors defined? #3 - I'm using the Jakarta Commons PoolingDataSource. I have used this before without any problems #4 - Something to look into. I'm closing my result sets, statements and connections (which returns them to the pool), but it might not be done in the best way. Mainguy, Mike wrote: The closest I ever came to this sort of problem involved the following: #1 Sending static content (and lots of it) through the servlet engine instead of using the web server. #2 Not having enough request processors and listeners configured. #3 Not using pooling for my connections and killing the DBMS with new connection requests. #4 Not properly closing/releasing my DBMS connections and consuming all available memory. So there you go, everything you should NOT do in a nutshell. Unless you're 100% proof-positive sure that it is a synchronization issue in your database portion, I would take a look at the above issues as potential problem areas. As far as synchronization is concerned, the only thing I can recommend is to be sure you aren't using your ActionServlet or something high in the food chain as your target, otherwise that would seem to cause that sort of a problem. -Original Message- From: Nathan Rogers [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 12:51 PM To: [EMAIL PROTECTED] Subject: Struts and synchronization I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and its contents (to include attachments) are the property of Kmart Corporation (Kmart) and may contain confidential and proprietary information. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on information contained herein is strictly prohibited. Unauthorized use of information contained herein may subject you to civil and criminal prosecution and penalties. If you are not the intended recipient, you should delete this message immediately. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Nathan Rogers Library Technology Group [EMAIL PROTECTED] (608)261-1409 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] LEGAL NOTICE This electronic mail transmission and any accompanying documents contain information belonging to the sender which may be confidential and legally privileged. This information is intended only for the use of the individual or entity to whom this electronic mail transmission was sent as indicated above. If you are not the intended recipient, any disclosure, copying, distribution, or action taken in reliance on the contents of the information contained in this transmission is strictly prohibited. If you have received this transmission in error, please delete the message. Thank you - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
This will also, of course, lead to better performance, period, in your case. Sounds to me like you need something like a WorkerQueue where you put requests in a regular queque and a thread pool of anonymous worker threads run a FIFO collection. This is fairly standard stuff with Doug Lea's stuff on concurrent programming (try oswego doug lea in google). If you are single threaded, you will not be able to consistent. And, if you are multi-threaded, in the model, then there are numerous things you can do, even if the WorkerPool (or whatever Doug calls it, I forget) is but one thread. You an return the thread while the database is doing its stuff. Why not? There are a lot of creative solutions, once you use concurrent techniques. I hope this is helpful. If you don't need to return the results of the database, but just to update, then you can really make it hum, having the database stuff just in queque until the right time. I do this with helper computers doing little tasks for me on modem based home computers (with the consent of friends). I just have them pass a notice of what there ip address is to a queque with a time, and when I need a little work done, I pass it via a tunnel to the freshest ip address, which is held at the application level. Of course, it is even easier with static ips. But, my friends, like me, don't have static ips. We are POOR! LOL. Micael At 04:54 PM 8/11/2003 -0700, Micael wrote: Have you thought about using a multi-threaded solution with a queque such that when your database is busy you can notify the user that things are being processed and giving them a link to check back on? At 12:46 PM 8/11/2003 0500, Nathan Rogers wrote: The request path for a standard action within my code goes something like this : Struts servlet - action - model - database - model - action - Velocity servlet Here's what I know about each issue you've brought up. #1 - Tomcat is configured to work with the Warp connector. I don't know exactly how this works (if it passes all requests to Tomcat or just the ones registered to a servlet) #2 - I'll have to check with the sysadmin. Where is the number of request processors defined? #3 - I'm using the Jakarta Commons PoolingDataSource. I have used this before without any problems #4 - Something to look into. I'm closing my result sets, statements and connections (which returns them to the pool), but it might not be done in the best way. Mainguy, Mike wrote: The closest I ever came to this sort of problem involved the following: #1 Sending static content (and lots of it) through the servlet engine instead of using the web server. #2 Not having enough request processors and listeners configured. #3 Not using pooling for my connections and killing the DBMS with new connection requests. #4 Not properly closing/releasing my DBMS connections and consuming all available memory. So there you go, everything you should NOT do in a nutshell. Unless you're 100% proof-positive sure that it is a synchronization issue in your database portion, I would take a look at the above issues as potential problem areas. As far as synchronization is concerned, the only thing I can recommend is to be sure you aren't using your ActionServlet or something high in the food chain as your target, otherwise that would seem to cause that sort of a problem. -Original Message- From: Nathan Rogers [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 12:51 PM To: [EMAIL PROTECTED] Subject: Struts and synchronization I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and its contents (to include attachments) are the property of Kmart Corporation (Kmart) and may contain confidential and proprietary information. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on information contained herein is strictly prohibited. Unauthorized use of information contained herein may subject you to civil and criminal prosecution and penalties. If you are not the intended recipient, you should delete this message immediately. - To unsubscribe, e-mail: [EMAIL
Re: Struts and synchronization
i have faced a similar problem but no struts involved, a simple jsp based application running on Apache Tomcat 4.0.4 . After around 4 4 hours the application use to hang, i saw something very surprising also, a thread woke up after 10 hours after i forced the other application accessing the database to close. This showed that the threads were just hanging indefinitely, and this was happening everywhere the code had to interact with the database, i could not replicate the problem later, but the problem is definitely with database, we were using the default Microsoft JDBC driver for SQL Server 2000. the default timeout on a table contention is -1 which is infinity. if this problem is (actually) due database do let me know what measures u took to stop the error. peace. - Original Message - From: Paul Thomas [EMAIL PROTECTED] To: struts-user [EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 3:20 PM Subject: Re: Struts and synchronization On 11/08/2003 17:50 Nathan Rogers wrote: I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). How do you conclude that PreparedStatement has synchronized methods? I've looked through the source for PreparedStatement (JDK 1.4.1) and can see no synchronized methods. This aside, how do you conclude that executing a synchronized method on two different objects of the same class would put one into a wait state (given that they will use different monitors)? Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? I think you're barking up the wrong tree here. You're either getting deadlocks in your database or you've got some dirty code in there that breaks thread safety. -- Paul Thomas +--+ -+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +--+ -+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts and synchronization
The closest I ever came to this sort of problem involved the following: #1 Sending static content (and lots of it) through the servlet engine instead of using the web server. #2 Not having enough request processors and listeners configured. #3 Not using pooling for my connections and killing the DBMS with new connection requests. #4 Not properly closing/releasing my DBMS connections and consuming all available memory. So there you go, everything you should NOT do in a nutshell. Unless you're 100% proof-positive sure that it is a synchronization issue in your database portion, I would take a look at the above issues as potential problem areas. As far as synchronization is concerned, the only thing I can recommend is to be sure you aren't using your ActionServlet or something high in the food chain as your target, otherwise that would seem to cause that sort of a problem. -Original Message- From: Nathan Rogers [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 12:51 PM To: [EMAIL PROTECTED] Subject: Struts and synchronization I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and its contents (to include attachments) are the property of Kmart Corporation (Kmart) and may contain confidential and proprietary information. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on information contained herein is strictly prohibited. Unauthorized use of information contained herein may subject you to civil and criminal prosecution and penalties. If you are not the intended recipient, you should delete this message immediately. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
On 12/08/2003 14:13 Nathan Rogers wrote: [snip] I am exploring all the possible things that could cause it to die; here specifically is the scenario that results in responses no longer being handled. The exact configuration for the servlet is Struts 1.1 Velocity Tools 1.0 Tomcat 4.0.2 and Apache 1.3.23 connected using the WarpConnection Oracle 8i backend database 1) Start up a request for an action 2) Reload the servlet using the manager servlet 3) Watch everything crawl to a halt while Warp spins its wheels It very well might have nothing at all to do with the Struts 1.1 framework, but the same things did not happen when using Struts 1.0.2 FWIW, I've had occasional weird things happening when using the Tomcat manager (missed that in your original post - sorry) and I'm using 4.1.18 on some machines and 4.1.24 on others. The problem is always on my development machine (4.1.18) where I might reload dozens of times a day and then, every few days the reload seems to go into some kind of loop. Shutting down and restarting Tomcat fixes it. This sounds rather like the problem your having. Do you ever get your lock-ups with a cleanly started-up Tomcat? BTW, I used to use the 4.0.x series with 1.0.2 but found that I was getting performance problems after switching to Struts 1.1. I'm not sure if it was a version problem or the fact I was doing more ambitious jsps with lots of tags - I suspect the latter. -- Paul Thomas +--+-+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +--+-+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
Paul Thomas wrote: On 11/08/2003 17:50 Nathan Rogers wrote: Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? I think you're barking up the wrong tree here. You're either getting deadlocks in your database or you've got some dirty code in there that breaks thread safety. I am exploring all the possible things that could cause it to die; here specifically is the scenario that results in responses no longer being handled. The exact configuration for the servlet is Struts 1.1 Velocity Tools 1.0 Tomcat 4.0.2 and Apache 1.3.23 connected using the WarpConnection Oracle 8i backend database 1) Start up a request for an action 2) Reload the servlet using the manager servlet 3) Watch everything crawl to a halt while Warp spins its wheels It very well might have nothing at all to do with the Struts 1.1 framework, but the same things did not happen when using Struts 1.0.2 -- Paul Thomas +--+-+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +--+-+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
On 11/08/2003 17:50 Nathan Rogers wrote: I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). How do you conclude that PreparedStatement has synchronized methods? I've looked through the source for PreparedStatement (JDK 1.4.1) and can see no synchronized methods. This aside, how do you conclude that executing a synchronized method on two different objects of the same class would put one into a wait state (given that they will use different monitors)? Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? I think you're barking up the wrong tree here. You're either getting deadlocks in your database or you've got some dirty code in there that breaks thread safety. -- Paul Thomas +--+-+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +--+-+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
The request path for a standard action within my code goes something like this : Struts servlet - action - model - database - model - action - Velocity servlet Here's what I know about each issue you've brought up. #1 - Tomcat is configured to work with the Warp connector. I don't know exactly how this works (if it passes all requests to Tomcat or just the ones registered to a servlet) #2 - I'll have to check with the sysadmin. Where is the number of request processors defined? #3 - I'm using the Jakarta Commons PoolingDataSource. I have used this before without any problems #4 - Something to look into. I'm closing my result sets, statements and connections (which returns them to the pool), but it might not be done in the best way. Mainguy, Mike wrote: The closest I ever came to this sort of problem involved the following: #1 Sending static content (and lots of it) through the servlet engine instead of using the web server. #2 Not having enough request processors and listeners configured. #3 Not using pooling for my connections and killing the DBMS with new connection requests. #4 Not properly closing/releasing my DBMS connections and consuming all available memory. So there you go, everything you should NOT do in a nutshell. Unless you're 100% proof-positive sure that it is a synchronization issue in your database portion, I would take a look at the above issues as potential problem areas. As far as synchronization is concerned, the only thing I can recommend is to be sure you aren't using your ActionServlet or something high in the food chain as your target, otherwise that would seem to cause that sort of a problem. -Original Message- From: Nathan Rogers [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 12:51 PM To: [EMAIL PROTECTED] Subject: Struts and synchronization I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and its contents (to include attachments) are the property of Kmart Corporation (Kmart) and may contain confidential and proprietary information. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on information contained herein is strictly prohibited. Unauthorized use of information contained herein may subject you to civil and criminal prosecution and penalties. If you are not the intended recipient, you should delete this message immediately. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Nathan Rogers Library Technology Group [EMAIL PROTECTED] (608)261-1409 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]