Improve the speed of a Tomcat Server with MySQL

I’m developing an application with 3 sides, desktop (JavaFX), server (Tomcat) and Android.

And a MySQL Database Server.

The app receive mails and convert them into tasks. The tasks are sent to the android devices from the desktop app. The user of the Android device do stuff with the task and send the task with new information to the server.

The desktop app takes the data from the database.

Now it’s working, but goes too slowly from the desktop side, due to the server possibly having a big payload.

The server has 3 tasks:

  • JavaMail email reader, and write in the database.
  • Send PUSH messages to the Android devices and receive some information from them, and write in the database.
  • Receive the GPS position from the Android devices, and write it in the database.

My doubts are:

A)Separate the server side in 3 projects.

  1. Mail reader
  2. Send PUSH to the Android devices.
  3. GPS position receptor.

B)Separate the database in 2 databases:

  1. For the GPS position.
  2. For the info of the tasks.

This steps will make the app faster?

Edit to answer Clinton Bosch:

I´m using Hibernate to connect to the database, here is my hibernate config file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>

        <property name="hibernate.c3p0.min_size">2</property>
        <property name="hibernate.c3p0.max_size">150</property>
        <property name="hibernate.c3p0.timeout">100</property>
        <property name="hibernate.c3p0.max_statements">0</property>


        <property name='connection.username'>root</property>

        <!-- Database connection settings -->
        <property name='connection.driver_class'>com.mysql.jdbc.Driver</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name='connection.pool_size'>10</property>

        <!-- SQL dialect -->
        <property name='dialect'>org.hibernate.dialect.MySQLDialect</property>

        <!-- Echo all executed SQL to stdout -->
        <property name='show_sql'>false</property>

        <!-- Mapping files -->
    </session-factory>
</hibernate-configuration>

2

Are you using a connection pool? very often I have seen developers using an application server without a connection pool and the majority of the time is spent establishing DB connections which are very heavy processes.

Apart from that using a profiler like jprofiler (for which you can get an eval license) would be your best port of call to diagnose your problem.

Microservices (separate servers) is quite a popular architecture especially in large scale applications because a failure in a single part of it does not mean everything stops (one of many reasons to use this architecture). The negative is that it does require more resources (one of many reasons not to use this architecture).

That being said, tomcat is a very powerful application server and I am running it with enterprise applications serving thousands of requests per minute without issue.

It is difficult to advise without having the full picture wrt size etc, but I would start by profiling.

2

Keep the db writes async, so when user sends gps or anything else, make a thread safe POJO with all the details, set it to a class that implements Runnable and put it in to a queue.

Natural question is what happens if server fails? Question from me is : how important is that? If a few 100 inserts fails will the users lose money? Stop using the app? if no then let it be!

You can then push jobs in to a queue of java managed threads using a thread pool executor.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Improve the speed of a Tomcat Server with MySQL

I’m developing an application with 3 sides, desktop (JavaFX), server (Tomcat) and Android.

And a MySQL Database Server.

The app receive mails and convert them into tasks. The tasks are sent to the android devices from the desktop app. The user of the Android device do stuff with the task and send the task with new information to the server.

The desktop app takes the data from the database.

Now it’s working, but goes too slowly from the desktop side, due to the server possibly having a big payload.

The server has 3 tasks:

  • JavaMail email reader, and write in the database.
  • Send PUSH messages to the Android devices and receive some information from them, and write in the database.
  • Receive the GPS position from the Android devices, and write it in the database.

My doubts are:

A)Separate the server side in 3 projects.

  1. Mail reader
  2. Send PUSH to the Android devices.
  3. GPS position receptor.

B)Separate the database in 2 databases:

  1. For the GPS position.
  2. For the info of the tasks.

This steps will make the app faster?

Edit to answer Clinton Bosch:

I´m using Hibernate to connect to the database, here is my hibernate config file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>

        <property name="hibernate.c3p0.min_size">2</property>
        <property name="hibernate.c3p0.max_size">150</property>
        <property name="hibernate.c3p0.timeout">100</property>
        <property name="hibernate.c3p0.max_statements">0</property>


        <property name='connection.username'>root</property>

        <!-- Database connection settings -->
        <property name='connection.driver_class'>com.mysql.jdbc.Driver</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name='connection.pool_size'>10</property>

        <!-- SQL dialect -->
        <property name='dialect'>org.hibernate.dialect.MySQLDialect</property>

        <!-- Echo all executed SQL to stdout -->
        <property name='show_sql'>false</property>

        <!-- Mapping files -->
    </session-factory>
</hibernate-configuration>

2

Are you using a connection pool? very often I have seen developers using an application server without a connection pool and the majority of the time is spent establishing DB connections which are very heavy processes.

Apart from that using a profiler like jprofiler (for which you can get an eval license) would be your best port of call to diagnose your problem.

Microservices (separate servers) is quite a popular architecture especially in large scale applications because a failure in a single part of it does not mean everything stops (one of many reasons to use this architecture). The negative is that it does require more resources (one of many reasons not to use this architecture).

That being said, tomcat is a very powerful application server and I am running it with enterprise applications serving thousands of requests per minute without issue.

It is difficult to advise without having the full picture wrt size etc, but I would start by profiling.

2

Keep the db writes async, so when user sends gps or anything else, make a thread safe POJO with all the details, set it to a class that implements Runnable and put it in to a queue.

Natural question is what happens if server fails? Question from me is : how important is that? If a few 100 inserts fails will the users lose money? Stop using the app? if no then let it be!

You can then push jobs in to a queue of java managed threads using a thread pool executor.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật