JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-6220

concurrency issues with http endpoints

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 3.1.2
  • Fix Version/s: None
  • Component/s: Core: Concurrency / Threading, Transport: HTTP(S) / Jetty
  • Labels:
    None
  • Environment:

    Java 5, Mule 3.1.2 StandAlone

  • User impact:
    Very High
  • Configuration:
    Hide

    <?xml version="1.0" encoding="UTF-8"?>
    <mule xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:https="http://www.mulesoft.org/schema/mule/https"
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xsi:schemaLocation="
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd">

    <flow name="http-test-flow" >
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="test" encoding="ISO-8859-1"/>

    <http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://localhost:8080/#[header:INBOUND:http.request]" encoding="ISO-8859-1"/>
    </flow>

    </mule>

    Show
    <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:http="http://www.mulesoft.org/schema/mule/http" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd"> <flow name="http-test-flow" > <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="test" encoding="ISO-8859-1"/> <http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://localhost:8080/#[header:INBOUND:http.request]" encoding="ISO-8859-1"/> </flow> </mule>
  • Log Output:
    Hide
    /**
     * Demonstrate Mule concurrency issues when using http endpoints.
     *
     * Just serve two text files containing the single character '1' and '2'
     * from a web server.
     *
     * Test against the web server. See it OK
     * Test against Mule. See it KO.
     */
    package test;

    import java.util.Vector;

    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.HttpStatus;
    import org.apache.commons.httpclient.methods.GetMethod;


    public class Test {


    private static String PORT = "8080";

    private static String URL1 = "http://localhost:" + PORT + "/test/1.txt";
    private static String URL2 = "http://localhost:" + PORT + "/test/2.txt";

    private static byte ONE = '0' + 1;
    private static byte TWO = '0' + 2;

        private static int NUMBER_OF_THREADS=100;
        
        protected static Thread dotest(int i) {
            return (new Thread() {
                public void run() {
                
                 String url = (getThreadId() % 2 == 0) ? URL1 : URL2;
                
                 GetMethod get = new GetMethod(url);
                 HttpClient client = new HttpClient();
                 try {
    int status = client.executeMethod(get);
    if (status==HttpStatus.SC_OK){
                     byte b[] = new byte[1];
                     get.getResponseBodyAsStream().read(b, 0, 1);
    if (URL1.equals(url) && b[0] != ONE) {
    System.out.println("KO "+ URL1 + " thread: "+ getThreadId() + " byte: " + b[0]);
    System.exit(-1);
    } else if(URL2.equals(url) && b[0] != TWO) {
    System.out.println("KO "+ URL2 + " thread: "+ getThreadId() + " byte: " + b[0]);
    System.exit(-1);
    }else {
    System.out.println("OK " + getThreadId() + " url=" + url + " byte: " + b[0]);
    }
    } else {
    System.out.println("HTTP Status " + status);
    }
                 } catch(Exception e){
                 e.printStackTrace();
                 }
                }
            });
        }

        private static Vector<Thread> v=new Vector<Thread>();
        
        public static void main(String [] args) throws Exception {
         long startTime=System.currentTimeMillis();
            for(int i=0;i<NUMBER_OF_THREADS;i++) {
                Thread t=dotest(i);
                t.start();
                v.add(t);
            }

            for(int i=0;i<v.size();i++) {
                Thread t=(Thread) v.get(i);
                t.join();
            }
            
            System.out.println("Time: "+(System.currentTimeMillis()-startTime));
        }
        
    private static long getThreadId() {
    return Thread.currentThread().getId();
    }
        
      
    }
    Show
    /**  * Demonstrate Mule concurrency issues when using http endpoints.  *  * Just serve two text files containing the single character '1' and '2'  * from a web server.  *  * Test against the web server. See it OK  * Test against Mule. See it KO.  */ package test; import java.util.Vector; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; public class Test { private static String PORT = "8080"; private static String URL1 = "http://localhost:" + PORT + "/test/1.txt"; private static String URL2 = "http://localhost:" + PORT + "/test/2.txt"; private static byte ONE = '0' + 1; private static byte TWO = '0' + 2;     private static int NUMBER_OF_THREADS=100;          protected static Thread dotest(int i) {         return (new Thread() {             public void run() {                           String url = (getThreadId() % 2 == 0) ? URL1 : URL2;                           GetMethod get = new GetMethod(url);              HttpClient client = new HttpClient();              try { int status = client.executeMethod(get); if (status==HttpStatus.SC_OK){                  byte b[] = new byte[1];                  get.getResponseBodyAsStream().read(b, 0, 1); if (URL1.equals(url) && b[0] != ONE) { System.out.println("KO "+ URL1 + " thread: "+ getThreadId() + " byte: " + b[0]); System.exit(-1); } else if(URL2.equals(url) && b[0] != TWO) { System.out.println("KO "+ URL2 + " thread: "+ getThreadId() + " byte: " + b[0]); System.exit(-1); }else { System.out.println("OK " + getThreadId() + " url=" + url + " byte: " + b[0]); } } else { System.out.println("HTTP Status " + status); }              } catch(Exception e){              e.printStackTrace();              }             }         });     }     private static Vector<Thread> v=new Vector<Thread>();          public static void main(String [] args) throws Exception {      long startTime=System.currentTimeMillis();         for(int i=0;i<NUMBER_OF_THREADS;i++) {             Thread t=dotest(i);             t.start();             v.add(t);         }         for(int i=0;i<v.size();i++) {             Thread t=(Thread) v.get(i);             t.join();         }                  System.out.println("Time: "+(System.currentTimeMillis()-startTime));     }      private static long getThreadId() { return Thread.currentThread().getId(); }         }
  • Similar Issues:
    None

Description

Problem with http

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    Test.java
    14/Jun/12 10:05 AM
    3 kB
    j j
  2. Java Source File
    Test.java
    10/May/12 12:05 PM
    3 kB
    j j

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds
Hide
Permalink
j j added a comment - 10/May/12 12:05 PM

Test Class

Show
j j added a comment - 10/May/12 12:05 PM Test Class
Hide
Permalink
David Dossot added a comment - 01/Jun/12 12:09 PM

What errors do you get on Mule's side?

My first impression is that you're relying on Mule's default threading configuration (16 threads for receivers and 16 for dispatchers) and then you bombard it with 100 concurrent threads performing synchronous interactions that are timely bound to the remote synchronous response of another server.

Try sizing the threading model (receivers and dispatchers) of the HTTP transport to the same size it is sized on the target web server and run the test again.

Show
David Dossot added a comment - 01/Jun/12 12:09 PM What errors do you get on Mule's side? My first impression is that you're relying on Mule's default threading configuration (16 threads for receivers and 16 for dispatchers) and then you bombard it with 100 concurrent threads performing synchronous interactions that are timely bound to the remote synchronous response of another server. Try sizing the threading model (receivers and dispatchers) of the HTTP transport to the same size it is sized on the target web server and run the test again.
Hide
Permalink
j j added a comment - 02/Jun/12 12:16 PM

I get no errors on Mule's side.

I'm not sure I understand how would changing the threading configuration solve the issue. I can not know neither how many simultanious connections will Mule be presented with nor how many will the target server handle concurrently.

What I would expect would be for Mule to just handle 16 requests at a time and hold the rest waiting, but to serve to each request the corresponding content. I consider an error is for Mule to return the content of 2.txt to a request for 1.txt (both static files with trival content).

The issue does not present in Mule 3.2.1

Show
j j added a comment - 02/Jun/12 12:16 PM I get no errors on Mule's side. I'm not sure I understand how would changing the threading configuration solve the issue. I can not know neither how many simultanious connections will Mule be presented with nor how many will the target server handle concurrently. What I would expect would be for Mule to just handle 16 requests at a time and hold the rest waiting, but to serve to each request the corresponding content. I consider an error is for Mule to return the content of 2.txt to a request for 1.txt (both static files with trival content). The issue does not present in Mule 3.2.1
Hide
Permalink
David Dossot added a comment - 04/Jun/12 11:34 AM

I'm sorry, I misunderstood the issue you were facing. It seems the problem was in caching/re-using the wrong outbound dynamic endpoint.

Glad this is fixed in 3.2.1!

Show
David Dossot added a comment - 04/Jun/12 11:34 AM I'm sorry, I misunderstood the issue you were facing. It seems the problem was in caching/re-using the wrong outbound dynamic endpoint. Glad this is fixed in 3.2.1!
Hide
Permalink
j j added a comment - 05/Jun/12 10:51 AM

Unfortunately I can't move to 3.2.1 (I'm stuck at Java 5). Could you please provide some pointers to how to workaround the issue?

Show
j j added a comment - 05/Jun/12 10:51 AM Unfortunately I can't move to 3.2.1 (I'm stuck at Java 5). Could you please provide some pointers to how to workaround the issue?
Hide
Permalink
David Dossot added a comment - 05/Jun/12 11:19 AM

I'm afraid the issue is not only in the HTTP transport but in the core module, where dynamic endpoints are defined. So patching may be complicated.

Not sure what to suggest... maybe try compiling 3.2.1 on Java 5?

Show
David Dossot added a comment - 05/Jun/12 11:19 AM I'm afraid the issue is not only in the HTTP transport but in the core module, where dynamic endpoints are defined. So patching may be complicated. Not sure what to suggest... maybe try compiling 3.2.1 on Java 5?
Hide
Permalink
Pablo Kraan added a comment - 12/Jun/12 01:28 PM

Can you tried on mule 3.1.3? There were many fixes related to dynamic endpoints on that version.

Show
Pablo Kraan added a comment - 12/Jun/12 01:28 PM Can you tried on mule 3.1.3? There were many fixes related to dynamic endpoints on that version.
Hide
Permalink
j j added a comment - 14/Jun/12 10:04 AM

I would, but I can't find this version anywhere.

Trying to get to the bottom of this, I modified the test class (see new attachment) so that it would append the test thread id to the URL so that I would be able to trace it by setting

log4j.logger.org.mule.endpoint.DynamicOutboundEndpoint=DEBUG
log4j.logger.org.mule.transport.http.HttpMessageReceiver=DEBUG

Unfortunately, the issue does not present itself. While not useful for me (as I don't see how to dig deeper), it might ring a bell to somebody.

Show
j j added a comment - 14/Jun/12 10:04 AM I would, but I can't find this version anywhere. Trying to get to the bottom of this, I modified the test class (see new attachment) so that it would append the test thread id to the URL so that I would be able to trace it by setting log4j.logger.org.mule.endpoint.DynamicOutboundEndpoint=DEBUG log4j.logger.org.mule.transport.http.HttpMessageReceiver=DEBUG Unfortunately, the issue does not present itself. While not useful for me (as I don't see how to dig deeper), it might ring a bell to somebody.
Hide
Permalink
j j added a comment - 14/Jun/12 10:05 AM

Test class which appends a Query String to the URL.

Show
j j added a comment - 14/Jun/12 10:05 AM Test class which appends a Query String to the URL.
Hide
Permalink
j j added a comment - 22/Jun/12 06:23 AM

Looks like this changeset might be the fix.

Show
j j added a comment - 22/Jun/12 06:23 AM Looks like this changeset might be the fix.

People

  • Assignee:
    Unassigned
    Reporter:
    j j
Vote (0)
Watch (3)

Dates

  • Created:
    10/May/12 12:03 PM
    Updated:
    Friday 03:29 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.