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.
- Mail reader
- Send PUSH to the Android devices.
- GPS position receptor.
B)Separate the database in 2 databases:
- For the GPS position.
- 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.