Saturday, November 30, 2013

Java EE Architecture with Firebase

The architecture for our game probably would be different from a typical Java EE architecture (displayed below) due to of firebase. 



A typical Java EE application architecture

There are a few technique how to do asynchronous communication between clients and server (Websockets, AJAX).

The basic usage of Firebase is on client tier (JS), in this scope we don´t need Data Tier and Bussiness Tier from image above. We can only post HTML page with JS to client and then everything is let on clients web browser. At first user log in (firebase support simply login) and then only communicate with firebase.

In our project is nessesery server synchronization, so that  there is Firebase like a serial bus.
1, choice - firebase like a serial bus and main datastorage. Server reads from queue (first firebase) and counts using date from firebase. Then push data to second firebase for showing at client.
Here could be a typical Java EE architecture, but there is a problem with asynchronous getting data from firebase. Solution is waiting for data - that will be very slowly when you will need a lot of diffrent data from firebase for counting (solution should be a DTO).
The another solution is change architecture a little bit. Before Service layer add new layer, which prepare data for service layer. So service layer use dao layer only for create, update, delete.

2, choice - server reads from queue but counts from his local data (in-memory,rdbms) which it reached from firebase callbacks before. This is very efficient concept. But it dont be using scaling of firebase. And my master thesis is about firebase.

I decide to use the first choice. And data from firebase load and write throught prepare data/service/dao tier.

1 comment:


  1. Hi, thanks for your post but I'm new to firebase and I can not understand something well:
    Maybe you are saying that you should use the methods of inserting and obtaining data from firebase instead of some persistence engine like hibernate and some entity manager of the normally used DAOS.

    I try to create a backend for a web app (web client) and a mobil app (android).

    Thank you very much in advance, I hope you can help me.

    Regards,
    Richard.

    ReplyDelete