Instantiating multiple instances in Google App Engine JAVA

I am testing Google App Engine using JAVA and I want to test the parallel execution of multiples instances. However, I don't know how to activate the multiples instances.

I tried to run this servlet in another browser (also I tried to make concurrent calls on another machine - with a different IP address)

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
import java.math.*;
public class SimpleServlet extends HttpServlet
{
  //A variable that is NOT thread-safe!

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    doPost(req, resp);
  }
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
     int counter = 0;
    resp.getWriter().println("<HTML><BODY>");
    resp.getWriter().println(this + ": <br>");
    for (int c = 0; c < 10; c++)
    {
      resp.getWriter().println("Counter = " + counter + "<BR>");
      try
      {
        //Thread.currentThread().sleep( 500);
          for (int e=0;e<9999;e++) {
          }
        Thread.sleep(500);

        counter++;
      }
      catch (InterruptedException exc) {
        resp.getWriter().println("I can't sleep<BR>");
      }
    }
    resp.getWriter().println("</BODY></HTML>");
  }
}

      

Each servlet takes 5 seconds to process, but the requests are bundled into one instance, for example if I run this servlet 10 times, it took 50 seconds to process the last.

I tried using:

<threadsafe>true</threadsafe>

      

but it doesn't do anything.

I tried to change the settings

settings

no luck.

enter image description here

So what can I do?

+1


source to share


1 answer


Once installed <threadsafe>true</threadsafe>

, you will be able to handle parallel requests in one instance. So, if you need to test how your application is performing with multiple active instances, it's best to disable this option.



In addition, you can create a traffic generator to make many requests to your application and thus wake up more than one instance.

+1


source







All Articles