You are on page 1of 45

REAL TIME DATABASE

Seminar submitted to
KAVAYITRI BAHINABAI CHAUDHARI NORTH MAHARASHTRA
UNIVERSITY,JALGAON
In fulfillment of requirement for the award of degree of
BACHELOR OF ENGINEERING
Under the
Faculty of Engineering and Technology
In the discipline
Computer Engineering

By
Koustubh Rajkumar Mishra
T.E. Computer
Guide
Nilesh Choudhary
Profesor

Department of Computer Engineering


Godavari Foundation’s
GODAVARI COLLEGE OF ENGINEERING, JALGAON
(NAAC Accredited)
(An affiliated to Kavayitri Bahinabai Chaudhari North Maharashtra University,
Jalgaon)
YEAR 2018-2019
Godavari Foundation’s
GODAVARI COLLEGE OF ENGINEERING, JALGAON
(NAAC Accredited)
(An affiliated to Kavayitri Bahinabai Chaudhari North Maharashtra University,
Jalgaon)

CERTIFICATE

This is to certify that the T.E.Computer Seminar "REAL TIME DATABASE" submitted
by Koustubh Rajkumar Mishra In fulfillment of the degree of BACHELORS OF ENGI-
NEERING in the Department of COMPUTER ENGINEERING, Godavari College of
Engineering, Kavayitri Bahinabai Chaudhari North Maharashtra University, Jalgaon is
a bonafide record of work carried out by his in the Department of Computer Engineer-
ing, Kavayitri Bahinabai Chaudhari North Maharashtra University, Jalgaon under my
guidance and supervision. In my opinion this work has attained the standard fulfilling
the requirements of the regulations of the University.

Date:
Place:Jalgaon

Nilesh Choudhary Prof. Pramod B. Gosavi


GUIDE H.O.D.

Dr. V. G. Arajpure
PRINCIPAL
Godavari Foundation’s
Godavari College of Engineering, Jalgaon
DECLARATION / UNDERTAKING

I hereby declare that the work presented in this Seminar "REAL TIME DATABASE"
was carried out by me under the supervision of guide from January-2019 to April-2019.
This work or any part of this work is based on original research and has not been sub-
mitted by me to any University/Institution for the award of any degree.

Date:
Place: Jalgaon

Koustubh Rajkumar Mishra (Roll No.05)


ACKNOWLEDGEMENT

We consider ourself to be fortunate to get this opportunity to be part of a Seminar Report


on in REAL TIME DATABASE. We are sincerely grateful to Prof. Nilesh Chaudhary
(Guide) for his invaluable guidance, motivation and support at all stages and creating a
flexible and enjoyable environment to work in.

Special thanks to Prof. Pramod B. Gosavi (Head of Computer Engineering) for the
support and help us in completing this Seminar successfully.
Last but not least; we are thankful to the God, my dearly beloved Parents, all Faculty
Members, my Friends and all who directly or indirectly supported for completion

Koustubh Rajkumar Mishra (Roll No.05)


Contents

List of Figures iii

Abstract 1

1 INTRODUCTION 2

2 Discovery 4

3 A Real Time Database Survay 6


3.1 Reactive applications vs. pull-based databases . . . . . . . . . . . . . . 7
3.2 Earliest Deadline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Highest Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Value inflated deadline . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 FIREBASE 10
4.1 Beyond the marketing copy:- . . . . . . . . . . . . . . . . . . . . . . . 10
4.2 This make lot of sense if they are me But I understand that many of you
are not me, so I am sorry if you were not helped by that. . . . . . . . . . 11

5 FIREBASE HOSTING 15
5.1 Grow your app and retain users . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Google Analytics for Firebase . . . . . . . . . . . . . . . . . . . . . . 17
5.3 Firebase Predictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

6 FIREBASE FEATURES 19

i
7 RethinkDB :- 21
7.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.2 When is RethinkDB a good choice? . . . . . . . . . . . . . . . . . . . 22
7.3 Who is using RethinkDB in production? . . . . . . . . . . . . . . . . . 23
7.4 Is RethinkDB based on existing technology? . . . . . . . . . . . . . . . 24
7.5 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

8 MongoDB 26
8.1 MongoDB platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.2 MongoDB History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.3 FEATURE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

9 REAL TIME DATABASE MODEL 31

10 REAL TIME DATABASE TRANSACTION SCEDULING 33

11 DEADLOCK 35

12 CONCLUSION 37
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

ii
List of Figures

4.1 , . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 traditional and firebase . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Firebase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.1 Firebase Rael Time Database . . . . . . . . . . . . . . . . . . . . . . . 18

8.1 MongoDB New Technology . . . . . . . . . . . . . . . . . . . . . . . 27


8.2 All In The NoSQL Family . . . . . . . . . . . . . . . . . . . . . . . . 28

iii
Abstract

The purpose of this study is to introduce everyone with real time databases like Google
firebase API, Mongo DB, Re think DB and their features. Firebase is a Google pro-
vided API for database storage and syncing into your android, IOS or web application.
Rethink DB is the first open-source, scalable JSON database built from the ground up
for the real time web. Mongo DB is a product between relational database and nosql
database which uses distributed technology. A real-time database is one which stores
data to database and fetches data from it very quickly but Firebase is not just a real-time
database, it is much more than that. Mongo DB is non-relational database just stores
data without explicit and structured mechanisms to link data from different buckets to
one another.
Chapter 1

INTRODUCTION

Traditionally, real-time systems manage their data (e.g. chamber temperature, aircraft
locations) in application dependent structures. As real-time systems evolve, their ap-
plications become more complex and require access to more data. It thus becomes
necessary to manage the data in a systematic and organized fashion. Database man-
agement systems provide tools for such organization, so in recent years there has been
interest in database and real-time technology. The resulting integrated system, which
provides database operations with real-time constraints is generally called a real-time
database system (RTDBS) 1. Like a conventional database system, a RTDBS functions
as a repository of data, provides ecient storage, and performs retrieval and manipulation
of information. However, as a part of a real-time system, whose task are associated with
time constraints, a RTDBS, has the added burden of ensuring some degree of condence
in meeting the system’s timing requirements. Example applications that handle large
amounts of data and have stringent timing requirements include telephone switching
(e.g. translating an 800 number into an actual number), radar tracking and others. Arbi-
trage trading, for example, involves trading commodities in di erent markets at di erent
prices.
Since price discrepancies are usually short-lived, automated searching and process-
ing of large amounts of trading information are very desirable. In order to capitalize on
the opportunities, buy-sell decisions have to be made promptly, often with a time con-

2
REAL TIME DATABASE

straint so that the nancial overhead in performing the trade actions are well compensated
by the benet resulting from the trade. As another example, a radar surveillance system
detects aircraft images or radar signatures. These images are then matched against a
database of known images.
The result of such match is used to drive other system actions, for example, in
choosing a combat strategy. Conventional database systems are not adequate for this
type of application. They di er from a RTDBS in many aspects. Most importantly RT-
DBSs have di erent performance goals, correctness criteria, and assumptions about the
applications. Unlike a conventional database system, whose main objective is to 2 Ben
Kao and Hector Garcia-Molina provide fast average response time, a RTDBS may be
evaluated based on how often transactions miss their deadlines, the average lateness or
tardiness of late transactions, the cost incurred in transactions missing their deadlines,
data external consistency (how current the values of data are in reecting the state of the
external world), and data temporal consistency (values of data in the database should
be taken from the external world at similar times) [50]. As a real-time system, speci-
cations related to timing constraints are usually supplied by the application designers.
For most cases, these timing requirements are expressed as deadlines for transactions.
Transactions of this sort, with which explicit time constraints are associated, are termed
real-time transactions. As mentioned above, a RTDBS can be viewed as a value-added
database system that supports real-time transactions.

GF’s Godavari College of Engineering, Jalgaon 3


Chapter 2

Discovery

Real-time Database is a cloud-hosted database. Data is stored as JSON format and


synchronized continuously to each associated client. When you build cross-platform
applications with IOS, Android, and JavaScript SDKs, the greater part of your cus-
tomers demand is based on one Real-time Database instance and consequently getting
updates with the most current data. A Database is an organized collection of data.
Databases can be stored locally on your computer or can be stored in cloud storages.
Every application whether android, IOS or web application, it has its own database.
In the android application, we can create databases using SQLite, shared preferences,
websites or some cloud-based storage sites. The basic idea behind creating database is
to store data systematically and fetch data when required. Firebase is also a database
backend for android, iOS and web applications. Firebase is Google provided API to
create a database and fetch from it in real time with only a few lines of code. Data is
stored as JSON and is accessible from all the platforms. MongoDB is an opensource
document database that provides high performance, high availability, and automatic
scaling. RethinkDB has a query language that supports really useful queries like ta-
ble joins and group by, and is easy to setup and learn. Real-Time Data Base System
can be defined as those computing systems that are designed to operate in a timely
manner.Real-time databases make it easy to implement reactive applications, because
they keep your critical information up-to-date. But how do they work and how do they

4
REAL TIME DATABASE

scale? In this article, we dissect the real-time query features of Meteor, RethinkDB,
Parse and Firebase to uncover scaling limitations inherent to their respective designs.
We then go on to discuss and categorize related real-time systems and share our lessons
learned in providing real-time queries without any bottlenecks in

GF’s Godavari College of Engineering, Jalgaon 5


Chapter 3

A Real Time Database Survay

A real-time transaction has to be completed by its deadline to be of full benet to the


system. Such guarantees are usually hard to ensure. In case a transactions deadline
is not met, the transaction is called a tardy transaction. Real-time database systems
di er in the way tardy transactions are handled, and this issue is generally referred to
as the overload management problem. A tardy transaction may carry positive, zero,
or negative residual value to the system. For the positive case, even though the benet
obtained by completing the tardy transaction is usually less than its full edged value, the
system should still complete it, if possible. The system may, however, choose to lower
the transaction’s priority so that non-tardy transactions are given preferential treatment,
for example, in accessing system resources. When a tardy transaction completely loses

6
REAL TIME DATABASE

its value (zero residual value case), it should be dropped to free system resources for
the benet of other transactions. Finally, when a tardy transaction carries negative value,
the system may choose to raise the transaction’s priority so that it can be completed as
soon as possible to diminish the cost incurred due to it tardiness. On the other hand,
the system may lower the transaction’s priority or even drop it so that other transactions
have a better chance of meeting their deadlines.
The decision is dependent upon the application semantics. In the extreme case that
a system cannot a ord having a tardy transaction (e.g. in nuclear power plant control),
the system is said to be a hard real-time database system otherwise, if tardy transac-
tions are tolerated even though they may be undesirable (e.g. arbitrage trading), we say
that the system is a soft real-time database system. It is argued in [51] that with cur-
rent technology, it is very hard to provide an absolute guarantee on meeting transaction
deadlines, and therefore, RTDBSs are mostly limited to soft real-time systems. There
are several factors that make it hard for a RTDBS to meet all deadlines. Firstly, the exe-
cutions of database transactions are usually data and resource dependent. To guarantee
satisfaction of transaction deadlines requires enormous excess resource to accommo-
date the highest system load. Secondly, full transaction support involves many database
protocols which are highly unpredictable in their execution times3

3.1 Reactive applications vs. pull-based databases


In recent years, people have come to expect reactivity from their applications, i.e. they
assume that changes made by other users are immediately reflected in the interfaces they
are using. However, building such applications with traditional database technology is
difficult, because systems for data storage and retrieval have been developed around a
purely pull-basedrequest-response access pattern for decades. If you want to brush up
your knowledge on this kind of database systems, have a look at our database survey:

NoSQL Databases:
a Survey and Decision Guidance

GF’s Godavari College of Engineering, Jalgaon 7


REAL TIME DATABASE

Together with our colleagues at the University of Hamburg, we that is Felix Gessert,
Wolfram Wingerath, Steffen medium.baqend.com
Responding to the need for reactivity on the database side, a new class of database
systems have emerged that are natively push-oriented and thus promise to ease devel-
opment of reactive (web) applications. These systems are often referred to as real-time
databases, because they keep data at the client in-sync with current database state in
realtime, i.e. immediately after change.

Preserving data consistency:-


Although the real-time database system may seem like a simple system, problems arise
during overload when two or more database transactions require access to the same por-
tion of the database. A transaction is usually the result of an execution of a program that
accesses or changes the contents of a database. A transaction is different from a stream
because a stream only allows read-only operations, and transactions can do both read
and write operations. This means in a stream, multiple users can read from the same
piece of data, but they cannot both modify it. A database must let only one transaction
operate at a time to preserve data consistency. For example, if two students demand to
take the remaining spot for a section of a class and they hit submit at the same time,
only one student should be able to register for it.
Real-time databases can process these requests utilizing scheduling algorithms for con-
currency control, prioritizing both students requests in some way. Throughout this arti-
cle, we assume that the system has a single processor, a disk based database, and a main
memory pool.
In real-time databases, deadlines are formed and different kinds of systems respond to
data that does not meet its deadline in different ways. In a real-time system, each trans-
action uses a timestamp to schedule the transactions. A priority mapper unit assigns a
level of importance to each transaction upon its arrival in the database system that is
dependent on how the system views times and other priorities. The timestamp method
relies on the arrival time in the system. Researchers indicate that for most studies, trans-

GF’s Godavari College of Engineering, Jalgaon 8


REAL TIME DATABASE

actions are sporadic with unpredictable arrival times. For example, the system gives an
earlier request deadline to a higher priority and a later deadline to a lower priority.[7]
Below is a comparison of different scheduling algorithms.

3.2 Earliest Deadline


PT = DT - The value of a transaction is not important. An example is a group of people
calling to order a product.

3.3 Highest Value


PT = 1/VT - The deadline is not important. Some transactions should get to CPU based
on criticalness, not fairness. This is an example of least slack that can wait the least
amount of time. If the telephone switchboards were overloaded, people who call 911
should get priority.

3.4 Value inflated deadline


PT = DT/VT - Gives equal weight to deadline and values based on scheduling. An
example is registering for classes where the student selects a block of classes that he
wishes to take and presses submit. In this scenario, higher priorities often take up
precedence. A school registration system probably uses this technique when the server
receives two registration transactions. If one student had 22 credits and the other had
100 credits, the person with 100 credits would take priority (Value based scheduling).

GF’s Godavari College of Engineering, Jalgaon 9


Chapter 4

FIREBASE

Firebase is a mobile and web application development platform developed by Firebase,


Inc. in 2011, then acquired by Google in 2014.As of October 2018, the Firebase plat-
form has 18 products,which are used by 1.5 million apps.t seems like there is an app for
everything these days. Well, almost everything. I have not found an app that helps me
remove impacted earwax. It happens to me sometimes, and it is super obnoxious. But
someone could build it! I will contribute to your Kickstarter.
If you are the enterprising sort of person that tackles humanity is urgent needs with a
mobile app, you will want to know about Firebase. Firebase is Googles mobile applica-
tion development platform that helps you build, improve, and grow your app.Here it is
again in bigger letters, for impact:Firebase is Googles mobile application development
platform that helps you build, improve, and grow your app.

4.1 Beyond the marketing copy:-


I have mixed feelings when someone asks me What is Firebase? (which happens a lot,
since I work on it). On the one hand, I am glad to know there is interest! Thanks for
asking On the other hand, there is so much to it, where do I even begin? The definition
above is accurate, but it is not very specific at all. I like retro games, so I will try to
explain Firebase again with a picture:

10
REAL TIME DATABASE

Figure 4.1: ,

4.2 This make lot of sense if they are me But I under-


stand that many of you are not me, so I am sorry if
you were not helped by that.
All joking aside (for the remainder of this paragraph only), Firebase is a toolset to build,
improve, and grow your app, and the tools it gives you cover a large portion of the ser-
vices that developers would normally have to build themselves, but dont really want to
build, because they had rather be focusing on the app experience itself. This includes
things like analytics, authentication, databases, configuration, file storage, push mes-
saging, and the list goes on. The services are hosted in the cloud, and scale with little
to no effort on the part of the developer. When I say hosted in the cloud, I mean that the
products have backend components that are fully maintained and operated by Google.
Client SDKs provided by Firebase interact with these backend services directly, with no
need to establish any middleware between your app and the service. So, if you are using
one of the Firebase database options, you typically write code to query the database in

GF’s Godavari College of Engineering, Jalgaon 11


REAL TIME DATABASE

your client app.


This is different than traditional app development, which typically involves writing
both frontend and backend software. The frontend code just invokes API endpoints
exposed by the backend, and the backend code actually does the work. However, with
Firebase products, the traditional backend is bypassed, putting the work into the client.
Administrative access to each of these products is provided by the Firebase console.

Figure 4.2: traditional and firebase

If you identify as a backend engineer, you might be hearing this and thinking that
your job is being eliminated OMG, no more backendsâĂŁ-âĂŁnow I have to learn
frontend development This is not really true, as there are some things that simply ought
to be on the backend for a variety of reasons. Firebase recognizes this, and offers a way
to do some backend development, where it makes sense for the app you work on. So,
dont worry, your job is safe, and I will talk more about this later on.Anyway, at the time
of this writing, I count 17 individual products in the Firebase suite. Here is another
helpful picture:

GF’s Godavari College of Engineering, Jalgaon 12


REAL TIME DATABASE

Figure 4.3: Firebase

It is said that a picture is worth a thousand words. I counted 37 in the picture,


including two things that are not really words. Turns out, you are in luck today, because
I am going to try to use up the other metaphorical 963 words in this article to help
explain that picture a little better. But I am not going to count them. And if you want
to find out what Firebase is not, well, you will have to read all the way to the end
of this post. No skipping ahead You will miss all the jokes! What sort of apps is
Firebase good for? There is really no limit to the types of apps that can be helped
by Firebase products. There are only limits to the platforms it can be used on. iOS
and Android are the primary targets for the Firebase SDKs, and there is increasing
support for web, Flutter, Unity, and C++. You should also know there is an Admin
SDK available for a variety of languages, to be used with any backend components you
might require. On top of those SDKs, there is a library called FirebaseUI (Android, iOS,
web) that provides a bunch of helpful utilities to make development with Firebase even
easier. And there are also projects such as AngularFire that wrap the web SDKs for use
with Angular. These are open source. Firebase likes open source. Firebase Realtime
Database and Cloud Firestore provide database services. I listed them both as realtime,
cloud hosted, NoSQL databases. They have individual strengths and weaknesses, and
you may need to do some researchto figure out which one is better for your needs.

GF’s Godavari College of Engineering, Jalgaon 13


REAL TIME DATABASE

Hint: start with Cloud Firestore, as it likely addresses more of your needs (and its
also massively scalable). You can use either one, or both together, if that suits your
app.Its worth noting that Firestore is technically a Google Cloud product, not a Firebase
product. Why is it listed with Firebase? Firebase adds SDKs to use in your mobile
app to make direct data access possible, removing the need for that pesky middleware
component. There are other products listed here with a similar relationship with Google
Cloud, which I will also note.Whats really special about these databases is that they give
you realtime updates to data as it changes in the database. You use the client SDK to
set up a listener at the location of the data your app wants to use, and the listener gets
invoked with that data repeatedly, every time a change is observed. This lets you keep
your apps display fresh, without having to poll the data of interest.With realtime data
like this, our friend Greta uses realtime data in her games to maintain live leaderboards
of in-game events for everyone to see. Shawn uses them to provide messaging between
friends on his social network. Because we just dont have enough chat apps out there!

GF’s Godavari College of Engineering, Jalgaon 14


Chapter 5

FIREBASE HOSTING

Is a secure, global web hosting CDN (Content Delivery Network). It is really good at
quickly delivering static content (HTML, CSS, JS, images) using servers that are close
to your users. And you can get it set up quickly, with or without your custom domain,
along with a provisioned SSL certificate that costs you nothing. Firebase Hosting has
one important point of integration with the rest of Firebase, and that is through Cloud
Functions. Firebase Hosting lets you proxy the request and response to and from Cloud
Functions when writing HTTP type functions. And, even better, it will cache the re-
sponses from your functions, if you configure them properly. What a great way to build
a RESTful API
Truth be told, I can not tell you exactly what RESTful means. I am assuming you know.
Feel free to rant in the comments.lets you take advantage of a wealth of machine learn-
ing expertise from Google, without having to know anything about ML. This is great for
me, because I dont know anything about ML But what I get out of ML Kit is the ability
to recognize things that my device camera captures, such as text, faces, and landmarks.
And it can work on my mobile device with very limited computing power. For those
of your with more advanced understanding of ML (again, not me), you can upload a
TensorFlow model for more sophisticated use cases. The roadmap for machine learn-
ing products at Firebase.Shawn uses ML Kit to locate faces in the photos and videos
uploaded by the users of his social network, then he performs some image manipulation

15
REAL TIME DATABASE

on them. Greta doesnt use ML Kit yet, because there is no Unity implementation for the
SDK yet. Dang But if there was, she might use it to let people scan QR coupon codes
for free promotional in-game items.And that is it for the build group. Lots of useful
tools in there! But there is still much left to discuss about Firebase.

5.1 Grow your app and retain users


The grow group of products are these:

• Analytics

understand your users, and how they use your app

• Predictions

apply machine learning to analytics to predict user behavior

• Cloud Messaging

send messages and notifications to users

• Remote Config

customize your app without deploying a new version, monitor the changes

• A/B Testing

run marketing and usability experiments to see what works best

• Dynamic Links

enable native app conversions, user sharing, and marketing campaigns

GF’s Godavari College of Engineering, Jalgaon 16


REAL TIME DATABASE

• App Indexing

reengage users with Google Search integration

• InApp Messaging

engage your active user with targeted messages

5.2 Google Analytics for Firebase


Google Analytics for Firebase is the core of the grow offering. If you need to better
know your users, and how they make use of your app, Analytics can show you that.
When you publish an app for the first time, you might have an idea who your user base
is going to be, where they live, and how they might use your app. And those ideas might
be completely wrong in practice! The only way to know for sure is to collect data, and
thats where Analytics helps.There is waaay more to Google Analytics for Firebase than
can be summarized here, but there is one important thing to know, and thats the con-
cept of an audience. An audience is a group of users who have taken some predefined
actions in your app, share some user properties, or have common device characteris-
tics. You define the requirements for someone to become a member of an audience, and
Analytics will figure out which users belong to it, by analyzing the stream of events
that your app generates over time. This concept of an audience segmentation is pow-
erful, because you can target that audience with other Firebase products in the grow
category. Keep this concept of audience in mind as you read on Gretas game defines an
audience of players who have completed level 10, and made an in-game purchase (core
players). Shawns social network app defines an audience of people between the ages
of 18âĂŞ24, who have at least 50 friends on the network (social young adults). Once
these audiences have been defined in the Firebase console, and apps are updated to send
the correct events, the audiences will collect members. Greta and Shawn can then target

GF’s Godavari College of Engineering, Jalgaon 17


REAL TIME DATABASE

the audience members with information and offers of interest to these groups.

5.3 Firebase Predictions


Firebase Predictions builds on top of the data collected by Analytics to make predic-
tions (no surprises there) about which users in your app are likely to churn (not open
your app), and which will spend (money, on your app). These two new categories of
users are kind of like Analytics audiences, except you aren not required to do anything
to define how a user ends up in one of these groups. This is the magic of machine learn-
ing! Its just like the magic of the Sorting Hat from Harry Potter, except no one frets
about getting sorted into Hufflepuff.

Figure 5.1: Firebase Rael Time Database

GF’s Godavari College of Engineering, Jalgaon 18


Chapter 6

FIREBASE FEATURES

1 Authentication: Authentication feature in firebase let you let only authorised users ac-
cess your application. Firebase provides login through Gmail, Github, twitter, facebook
and also let the developer create custom authentication.

2 Hosting: Hosting is production-grade web content that facilities the developers. With
Hosting, you can rapidly and effectively send web applications and static content to a
Content Delivery Network (CDN) with a single command. It contains custom domain
support, Global CDN and Auto Provisioned SSL Certificate.

3 Messaging: It is a cross-platform messaging solution that lets you dependably con-


vey messages at zero expense. You can inform a customer that new email or other
information is accessible to sync. You can send notification messages to drive user
reengagement and maintenance.

4 Analytics: This feature enables the application developer to understand how users are
using his application. The SDK capture events and properties on its own and also al-
lows you to get custom data. The dashboard provides details like your most active user
or what feature of your application is used most. It also provides you with summarised

19
REAL TIME DATABASE

data.

5 Storage: Firebase also provides storage facility. It can store and retrieve content like
images, videos and audio directly from client SDK. Uploading and downloading is done
in the background. Data stores are safe and the only authorised user can access it.

6 Real-time Database: Database in firebase is a cloudbased database and does not need
SQL-based queries to store and fetch data. Database is highly reliable thus even if con-
nection is lost data is maintained.

7 Crash reporting: crash reporting feature on firebase creates reports of error in your
app after its release. Errors are grouped into different groups according to how severe
error is. You can also create custom events to catch steps leading to the crashing of the
application.

8 App Indexing: By using this component you easily get to index your application in
Google Search. For an instance, if your application is already installed in users de-
vice when he searches for related content, it will live your app directly from the search
results. If users have not installed your application yet, an install card shows up in
search results. 9. AdMob: It is a simple approach to adapt mobile apps with focused
in-application promoting. It is mobile advertising platform which you can use to create
revenue with the help of your application. It gives you extra application usage informa-
tion and analytics capabilities.

GF’s Godavari College of Engineering, Jalgaon 20


Chapter 7

RethinkDB :-

RethinkDB is a distributed, open-source database for building realtime web applica-


tions. It has an expressive query language that supports method chaining and distributed
joins. The database is easy to scale, with a robust clustering and automatic failover. Re-
thinkDBs signature feature is it is native support for live queries that push realtime
updates to your application. The company behind RethinkDB shut down last year after
struggling to build a sustainable business around the product. Many former RethinkDB
employees currently work for Stripe, where they help build infrastructure for developers
around the world. After the company behind RethinkDB closed its doors, the database
continued to live on as an open-source software project. Todays announcement elimi-
nates any remaining uncertainty about the project is health and status, ensuring a bright
future for the project in community hands. When the company behind RethinkDB shut
down last year, a group of former employees and members of the community formed an
interim leadership team and began devising a plan to perpetuate the RethinkDB open-
source software project by transitioning it to a community-driven endeavor. Todays
announcement by the Cloud Native Computing Foundation (CNCF) marks the culmi-
nation of that effort. The CNCF purchased the rights to the RethinkDB source code
and contributed it to The Linux Foundation under the permissive ASLv2 license. Re-
thinkDB is alive and well: active development can continue without disruption. Users
can continue to run RethinkDB in production with the expectation that it will receive

21
REAL TIME DATABASE

updates. The website, GitHub organization, and social media accounts will also con-
tinue operating. The interim leadership team will work with the community to establish
formal governance for the project. Under the aegis of The Linux Foundation, the project
has strong institutional support and the capacity to accept donations. Over the past sev-
eral months, members of the community have expressed interest in making donations to
fund ongoing RethinkDB development. We are now equipped to accept those donations
and put the money we raise to good use. Stripe has generously agreed to match up to
$ doller25,000 in donations. You can donate here to support RethinkDBs future as an
open-source project.

7.1 History
RethinkDB was founded in 2009, and open-sourced at version 1.2 in 2012 [5]. In
2015, RethinkDB released version 2.0, announcing that it was production-ready.[6] On
October 5, 2016, the company announced it was shutting down, transitioning members
of its engineering team to Stripe, and would no longer offer production support.[7][8]
On February 6, 2017, The Cloud Native Computing Foundation purchased the rights to
the source code and relicensed it under the Apache License 2.0.

7.2 When is RethinkDB a good choice?


RethinkDB is a great choice when your applications could benefit from realtime feeds to
your data. The query-response database access model works well on the web because
it maps directly to HTTP is request-response. However, modern applications require
sending data directly to the client in realtime. Use cases where companies benefited
from RethinkDBs realtime push architecture include:

• Collaborative web and mobile apps

• Streaming analytics apps

• Multiplayer games

GF’s Godavari College of Engineering, Jalgaon 22


REAL TIME DATABASE

• Realtime marketplaces

• Connected devices For example, when a user changes the position of a button in a
collaborative design app, the server has to notify other users that are simultaneously
working on the same project. Web browsers support these use cases via WebSock-
ets and long-lived HTTP connections, but adapting database systems to realtime needs
still presents a huge engineering challenge.RethinkDB is the first open-source, scalable
database designed specifically to push data to applications in realtime. It dramatically
reduces the time and effort necessary to build scalable realtime apps.

7.3 Who is using RethinkDB in production?


RethinkDB is being used in production by hundreds of technology startups, consulting
studios, and Fortune 500 companies. Here are some example use cases:

• Jive Software and Mediafly use RethinkDB to power reactive web and mobile apps

• Pristine.io and Narrative Clip use RethinkDB to power cloud infrastructure for con-
nected devices

• Platzi and Workshape.io use RethinkDB to power realtime analytics

• CMUNE and NodeCraft use RethinkDB to power massively scalable multiplayer


games

RethinkDB has a vibrant community of over 100,000 developers, and hundreds of con-
tributors from around the world

GF’s Godavari College of Engineering, Jalgaon 23


REAL TIME DATABASE

7.4 Is RethinkDB based on existing technology?


Implementing efficient realtime push architecture required redesigning most database
components, including the query execution engine, the distributed system, the caching
subsystem, and the storage engine. Because the architecture affects every database com-
ponent, RethinkDB has been implemented in C++ from scratch. RethinkDB was built
over five years by a team of database experts with the help of hundreds of contributors
from around the world. Secondly, realtime sync APIs are limited to syncing documents,
while RethinkDB is a general purpose database system. In RethinkDB you can run ar-
bitrary queries including table joins, subqueries, geospatial queries, aggregation, and
map-reduce. Realtime sync services have much more limited querying capabilities. Fi-
nally, realtime sync APIs are designed to be accessed directly from the browser. This
makes it very easy to get basic apps up and running, but limits the flexibility as the
app expands. RethinkDB is designed to be accessed from an application server, much
like a traditional database. This requires slightly more setup code, but allows a lot of
flexibility as the application becomes more sophisticated.

7.5 Features
1. NoSQL -
schema-less approach: Rethink DB is a JSON document database. A JSON document
represents a structured object consisting of key/value pairs. The value can be either a
primitive data type (integer, string, floating point number) or a nested JSON object (rep-
resented in document form). This means, of course, that JSON can describe arbitrarily
complex objects. Rethink DB stores documents in tables. While this might lead one to
think that Rethink DB has relational database ingredients, the fact is a table is simply
a logical container, the Rethink DB engineers chose to call that container table so that
developers comingfrom a relational background would feel comfortable. A table in Re-
think DB places no real restrictions on the structure of its contained documents. In the
relational world, all rows within a table necessarily have the same structure. But Re-

GF’s Godavari College of Engineering, Jalgaon 24


REAL TIME DATABASE

think DB is schema-less: No two documents, not even documents within the same table,
need to have the same structure. Of course, it is generally beneficial for all documents
in a table to have the same structure, as it simplifies organization and management. But
the flexibility is there, if needed.

2. Real time push architecture:


Typically, clients are in touch with alterations in database contests by querying the
database itself. Thus, if we want to figure what user A has updated in the database, we
will need to query it (in different approaches, depends which language is used). Never-
theless, the application is aware of changes only when polling the database. In Rethink
DB, this whole idea has changed. It provides a real-time push architecture. Clients can
listen do DB changes, that they are notified once there is any change, any time, without
a need to poll the database repeatedly.

3. Failover in Rethink DB:


Rethink DB supports failover, which requires that the cluster have at least three nodes
and tables be configured to have more than two shards. If a node becomes unavailable
and happens to host the primary replica for a table, then one of the secondary nodes is
selected by Rethink DB to become the new primary. No data is lost. Should the lost
node come back online, it will resume its position as primary.

4. JOINs and GMR: In Rethink DB, the equivalent of a relational JOIN operation can
actually be performed.

GF’s Godavari College of Engineering, Jalgaon 25


Chapter 8

MongoDB

MongoDB is a cross-platform document-oriented database program. Classified as a


NoSQL database program, MongoDB uses JSON-like documents with schemata. Mon-
goDB is developed by MongoDB Inc. and licensed under the Server Side Public Li-
cense (SSPL). MongoDB is an open source database management system (DBMS) that
uses a document-oriented database model which supports various forms of data. It
is one of numerous nonrelational database technologies which arose in the mid-2000s
under the NoSQL banner for use in big data applications and other processing jobs in-
volving data that doesn’t fit well in a rigid relational model. Instead of using tables
and rows as in relational databases, the MongoDB architecture is made up of collec-
tions and documents. How it works A record in MongoDB is a document, which is a
data structure composed of field and value pairs. MongoDB documents are similar to
JavaScript Object Notation objects but use a variant called Binary JSON (BSON) that
accommodates more data types. The fields in documents are akin to the columns in a
relational database, and the values they contain can be a variety of data types, includ-
ing other documents, arrays and arrays of documents, according to the MongoDB user
manual. Documents, which also must incorporate a primary key as a unique identifier,
are the basic unit of data in MongoDB. Collections contain sets of documents and func-
tion as the equivalent of relational database tables. Collections can contain any type
of data, but the restriction is the data in a collection cannot be spread across different

26
REAL TIME DATABASE

databases. The mongo shell is an interactive JavaScript interface to MongoDB which


allows users to query and update data, and conduct administrative operations. The shell
is a standard component of the open source distributions of MongoDB. Once MongoDB
is installed, users connect the mongo shell to their running MongoDB instances. The
BSON document storage and data interchange format used in MongoDB provides a
binary representation of JSON-like documents. Automatic sharding is another key fea-
ture that enables data in a MongoDB collection to be distributed across multiple systems
for horizontal scalability as data volumes and throughput requirements increase. The
NoSQL DBMS uses a single master architecture for data consistency, with secondary
databases which maintain copies of the primary database. Operations are automatically
replicated to those secondary databases for automatic failover.

Figure 8.1: MongoDB New Technology

8.1 MongoDB platforms


MongoDB is available in community and commercial versions through vendor Mon-
goDB Inc. MongoDB Community Edition is the open source release, while MongoDB
Enterprise Server brings added security features, an in-memory storage engine, admin-
istration and authentication features, and monitoring capabilities through Ops Manager.

GF’s Godavari College of Engineering, Jalgaon 27


REAL TIME DATABASE

A graphical user interface (GUI) called MongoDB Compass gives users a way to work
with document structure, conduct queries, index data and more. The MongoDB Con-
nector for BI allows users to connect the NoSQL database to their business intelligence
tools to visualize data and create reports using SQL queries. Following in the foot-
steps of other NoSQL database providers, MongoDB Inc. launched a cloud database
as a service called MongoDB Atlas in 2016. Atlas runs on AWS, Microsoft Azure and
Google Cloud Platform. More recently, MongoDB released a platform called Stitch
for application development on MongoDB Atlas, with plans to extend it to on-premises
databases.

Figure 8.2: All In The NoSQL Family

The company also added support for multi-document ACID transactions as part of Mon-
goDB 4.0 in 2018. Complying with the ACID properties – atomicity, consistency, iso-
lation and durability – across multiple documents expands the types of transactional
workloads that MongoDB can handle with guaranteed accuracy and reliability.

8.2 MongoDB History


MongoDB was created by Dwight Merriman and Eliot Horowitz, who had encountered
development and scalability issues with traditional relational database approaches while
building web applications at DoubleClick, an online advertising company that is now

GF’s Godavari College of Engineering, Jalgaon 28


REAL TIME DATABASE

owned by Google Inc. The name of the database was derived from the word humongous
to represent the idea of supporting large amounts of data.

8.3 FEATURE
1. Mongo DB makes it easy:

Mongo DB can consolidate any sort of information - any structure, any arrangement,
and any source - regardless of how frequently it changes, analytical engines can be real-
time and continuous.

2. Scalability:

MongoDB is built to scale out on commodity hardware, in your data center or in the
cloud. And without complex hardware or extra software

3. Real Time:

It can analyze data of any structure from the database, giving you results in real time,
without any data warehouse burdens.

4. High Performance:

Mongo DB provides high performance data persistence. Indexes support faster queries
so CRUD transaction perform smoothly. In support for embedded data models reduces
I/O action on database system.

GF’s Godavari College of Engineering, Jalgaon 29


REAL TIME DATABASE

5. Rich Query Language:

Mongo DB supports easy syntax for read and write operations (CRUD) as well as: Data
Aggregation Text Search and Geospatial Queries.

6. High Availability:

Mongo DBs replication facility, called replica set, provides-automatic failover and data
redundancy. It keeps similar informational index, giving excess and expanding infor-
mation accessibility.

7.Pricing:

Depends on which RDBMS of course, but Mongo DB is free and can run on Linux,
ideal for running on cheaper commodity kit.

GF’s Godavari College of Engineering, Jalgaon 30


Chapter 9

REAL TIME DATABASE MODEL

Any new transaction must go through an Admission Control component, which mon-
itors and manages the aggregate number of simultaneously active transactions within
the system in order to avoid transaction failure.
• Each new or resubmitted transaction is assigned a Priority Level, which arranges its
planning inclination in respect to the next simultaneous transactions inside the system.
• Before a transaction performs an operation on a data object, it must experience the
Concurrency Control part so as to accomplish the required synchronization. On the off
chance that the exchange’s demand for a granule is denied, the transaction will be put
into a Wait Queue.
• The waiting transaction will be reactivated when the requested granule becomes avail-
able, after which the transaction performs its operationSimilarly, if a transaction a thing
that is right now not in fundamental memory, an I/O ask for is started and the transac-
tion will be put into a hold up line.
• The holding up exchange will be reactivated when the requested granule becomes
available in fundamental memory, and there is no dynamic higher-need exchange.
• When a transaction completes all of its operations, it commits its result(s) and releases
all of the data items in its possession.

• A transaction may abort/restart a number of times before it commits. There are vari-

31
REAL TIME DATABASE

ous types of aborts :

- Terminating abort: An abort due to missing a deadline, or Self-abort âĂŞ a transaction


may abort itself due to an exceptional condition.

-Non-terminating abort: An abort due to a deadlock or a data conflict. In this case, the
transaction maybe restarted if its deadline remains feasible.

GF’s Godavari College of Engineering, Jalgaon 32


Chapter 10

REAL TIME DATABASE


TRANSACTION SCEDULING

Real Time database system provides feature with respect to standard physical resource
is the data objects stored in the database. Transactions accessing this data have to be
scheduled in accordance with real-time performance objectives. The scheduling pro-
cess of transactions in a real time database system consists of: Concurrency Control

Conflict Resolution Concurrency Control Protocols:

Locking, Time-stamping, Multiversion, Validation-all of which have the same goal i.e.,
enforcing serializability. These Protocols need to be modified and their trade-off(s)
must be reevaluated under RTDB systems.

1. Concurrency Control Protocol:

Locks are used to synchronize concurrent actions-Two-Phase Locking (2PL).All lock-


ing operations precedes the first unlock operation in the transaction, expanding phase
(locks are acquired), shrinking phase (locks are released), suffers from deadlock, prior-
ity inversion.

33
REAL TIME DATABASE

2. Conflict Resolution:

Priority-based Wound-Wait Conflict Resolution-the original scheme was designed to


use timestamps. It was modified so that the scheme uses priorities instead of times-
tamps. Modified scheme consist of High-Priority and Priority-Abort

GF’s Godavari College of Engineering, Jalgaon 34


Chapter 11

DEADLOCK

Whenever a set of transactions gets involved in a circular wait in what is known as


a wait-for graph. Five deadlock resolution policies that take into account: the timing
properties of the transactions, the cost of abort operations.

1. Policy1:
a. Always aborts the transaction invoking deadlock detection.

2. Policy 2:
a. Trace the deadlock cycle
b. Abort the first tardy transaction encountered in a deadlock cycle.
c. If no tardy transaction is found, abort the transaction with the furthest deadline.

3. Policy 3:
a. Trace the deadlock cycle.
b. Abort the first tardy transaction encountered in a deadlock cycle.
c. If no tardy transaction is found, abort the transaction with the earliest deadline.

4. Policy 4:
a. Trace the deadlock cycle, and abort the first tardy transaction encountered in a dead-

35
REAL TIME DATABASE

lock cycle.
b. If no tardy transaction is found, abort the transaction with the least criticalness.

5. Policy 5:
a. Abort the infeasible transaction with the least criticalness.
b. If all transactions are feasible, then abort a feasible transaction with the least critical-
ness.
c. This policy is sensitive to the accuracy of the computation time because it requires
information about remaining execution time
d. So, Total execution time requirements at the start of each transaction must be known

GF’s Godavari College of Engineering, Jalgaon 36


Chapter 12

CONCLUSION

In this paper we undergo comparison between firebase, Mongo DB and Rethink. We


came to the conclusion that -RealTime Data Base System can also be defined as Tra-
ditional Databases that uses an extension to give additional power to yield reliable re-
sponse. Since data is stored on cloud it is readily available any where. If your app does
run of a centralized DB, and is updated by a lot of users - then it is more than capable of
handling the Real-Time data updates between devices. We have studied about Google
provided firebase API, Mongo DB and Rethink and their unique features along with
drawbacks. By utilizing this feature, there is no necessity to make your own database or
own API, real time database handles all the components that usually come along with
creating a backend for applications This study provides an extensive survey of different
real-time systems research.

37
REAL TIME DATABASE

1 Dipinadamodaran B1 , ShirinSalim2AndSurekhamariumvargese3, P ERF ORM AN CEEV AL


5, No. 2, April 2016

2 Ebrahimabduljalil1,Dr. S.B. Thorat2, SecurityandConcurrencyControlInReal −


T imeDatabaseSystems : ASurvey, IJARCCE Vol. 5, Issue 2, February 2016

3 InternationalJournalOf InnovativeResearchInComputerAndCommunicationEngineering(
2007Certif iedOrganization), September 2016

4 Navdeep Singh, StudyOf GoogleF irebaseAP IF orAndroid, IJIRCCE(AnISO3297 :


2007Certif iedOrganization) Vol. 4, Issue 9, September 2016

5 Fadia A. Elbagir,AhmedKhalid, KhalidKhanf ar, ASurveyOf CommitP rotocolsInDistributed


2, 2016

GF’s Godavari College of Engineering, Jalgaon 38

You might also like