1

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>
  • 1
    What does your profiling say is the slow area? – Philip Kendall Dec 6 '14 at 15:25
  • the slow area is the desktop, bu i think that its due the Android devices are sending the position every minute, and the server records on the same database which the desktop consults. – vLopez Dec 6 '14 at 15:44
1

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.

  • See the edit, that is what you asked? – vLopez Dec 6 '14 at 17:29
  • Okay so you are using c3p0 pool, you will have to run thw profiler to see where the bottlenecks exist. Often it is something silly like a point query that could easily be solved with a cache or something – Clinton Bosch Dec 8 '14 at 19:36
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.