Ayub,

On 6/15/21 18:43, Ayub Khan wrote:
Chris,

below is the method responsible for returning the data to the service api,
and its returned from service to the Rest controller

public MenuList getMenuMobileListNormalizedCombo(long a, long b, boolean c,
long d) throws Exception {
Connection con = null;
CallableStatement callableStatement = null;
ResultSet rs = null;
ResultSet rs1 = null;
MenuList menuList = new MenuList();

try {
con = connectionManager.getConnetion();
con.setAutoCommit(false);
callableStatement = con.prepareCall("call
appschema.menu_pkg$get_menu_items(?,?,?,?,?,?)");
callableStatement.setLong(1, a);

if (c == 0)
callableStatement.setNull(2, Types.BIGINT);
else
callableStatement.setLong(2, b);

callableStatement.setString(3,"Y");

if(d == 0)
callableStatement.setString(4, null);
else
callableStatement.setLong(4, d);

callableStatement.setNull(5, Types.OTHER);
callableStatement.setNull(6, Types.OTHER);
callableStatement.registerOutParameter(5, Types.OTHER);
callableStatement.registerOutParameter(6, Types.OTHER);
callableStatement.setFetchSize(5);
callableStatement.execute();
rs = (ResultSet) callableStatement.getObject(5);
rs1 = (ResultSet) callableStatement.getObject(6);
MenuMobile menuMobile;

try {
while (rs.next()) {

menuMobile = new MenuMobile();
//setters removed
menuMobileList.add(menuMobile);
}
MenuCombo menuCombo;
while (rs1.next()) {
//setters removed

menuComboList.add(menuCombo);
}

menuList.setMenuComboList(menuComboList);
menuList.setMenuMobileList(menuMobileList);
} catch (SQLException e) {
LOG.error(e.getLocalizedMessage(), e);
}

con.commit();
con.setAutoCommit(true);
} catch (SQLException e) {
LOG.error(e.getLocalizedMessage(), e);
throw e;
} finally {
if (rs != null)
rs.close();

You need try/catch blocks around your close() calls, too. It's unlikely they will fail, but they can fail, and if they do, your other resource-management tasks will be skipped.

if (rs1 != null)
rs1.close();

if(callableStatement!=null)callableStatement.close();
if(con!=null)con.close();
}
return menuList;
}

Below is the signature of the rest controller api method



@RequestMapping(value = "/m_listAllItems", method = RequestMethod.GET,
produces = {"application/json;charset=UTF-8"})
@ResponseBody
public Object m_listAllMenus(@RequestParam("a") long a,
                                                    @RequestParam("b") String b,
                                                    @RequestParam("c") String c,
                                                    @RequestParam(value
= "d",defaultValue ="0") String d) {
     Object menuList = new Object();
     try {

         menuList = menuManagmentService.listAll(a, b, c, d); //this
service calls the dao in the service class
     } catch (Exception e) {
         LOG.error(e.getLocalizedMessage(), e);
     }

     return menuList;
}

How long does your CALL statement take to execute in the database? How many records is it returning? How many bytes of JSON are you generating? Calling JSON.toString(Object) isn't free. With any luck, your framework is streaming the JSON out to the HttpServletResponse instead of doing this:

String json = JSON.toString(menuList);

response.write(json);

But if a StringBuilder/StringBuffer/String is being guilt on the server, it can take some time. And a bunch of memory.

-chris

On Thu, Jun 10, 2021 at 8:10 AM Ayub Khan <ayub...@gmail.com> wrote:

Seeing client write waits on postgresql as attached in the image. Is there
any bottle neck which is causing the client write waits on postgresql ?

Below is the test setup

Jmeter-->(load balanced tomcat on ec2 instances)---->rds read replicas

All these are running on different ec2 instances in AWS cloud in the same
region

below is the config of the http connector on tomcat:

<Connector port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
                connectionTimeout="120000" maxThreads="50000"
maxConnections="50000"
                URIEncoding="UTF-8"
                redirectPort="8443" />

Below are the specs of the server:

Ec2 instance which is running tomcat 8.5

c5.9x large
36 vpcu
72GB memory
10GBPS network
EBS band width 9500


postgresql RDS db.r6g.16xlarge

512 GB memory
64 VCPU
25 Gibs network
AWS Gravitron cpu

--Ayub




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to