package com.musugundan;
import java.io.IOException;
import java.util.Date;
import javax.jdo.PersistenceManager;
import javax.servlet.http.*;
@SuppressWarnings("serial")
public class MusugundanServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.addHeader("Refresh", "0; URL=/musugundan");
resp.getWriter().println("Adding 100 records, Starting time " + new Date());
PersistenceManager pm = PMF.get().getPersistenceManager();
resp.flushBuffer();
//
int maxrecords = 1000;
for(long i=1;i<1000; i++)
{
Agent ag = new Agent("firstname" + i ,"lastname" + i,new Date());
resp.getWriter().println("Writing Record :" + i );
resp.flushBuffer();
pm.makePersistent(ag);
}
resp.getWriter().println("Added 100 records, Ending time " + new Date());
resp.flushBuffer();
}
}
When I set the maxrecords to 1000. It is error always. Means I cannot create 1000 records at a stretch.
I changed to 100. The timing went to 12 seconds to 25 seconds.
Change it to 1 and open multiple browsers with the instance of 100. It went on smoothly. Creating single record in a single request is pretty fast.
In Cloud computing make big things in a simpler way. That way it can work fast for its distributed nature of resources.
No comments:
Post a Comment