Вы находитесь на странице: 1из 18

VS

RavenDB vs MongoDB

CONTENTS

RavenDB vs MongoDB������������������������������������������������������������������������������������������������������������������������������� 2

1. Maintaining Data Integrity ������������������������������������������������������������������������������������������������������������������ 3

2. Querying & Aggregating Data�������������������������������������������������������������������������������������������������������������� 3

3. Performance��������������������������������������������������������������������������������������������������������������������������������������������6

4. Scaling Out Your Database�������������������������������������������������������������������������������������������������������������������8

5. Features����������������������������������������������������������������������������������������������������������������������������������������������������9

6. Integration With Your Organization’s Current Systems������������������������������������������������������������� 10

7. Caching And Concurrency������������������������������������������������������������������������������������������������������������������ 10

8. Data Security������������������������������������������������������������������������������������������������������������������������������������������11

9. Cloud Solutions������������������������������������������������������������������������������������������������������������������������������������� 12

10. Getting Started������������������������������������������������������������������������������������������������������������������������������������ 13

About RavenDB������������������������������������������������������������������������������������������������������������������������������������������ 14

1
RavenDB vs MongoDB

RavenDB is an open source Non-relational including a satisfied client with over 1.5
document database first developed in 2009 million instances on Point of Sale (PoS)
that specializes in online transaction pro- machines deployed worldwide. RavenDB
cessing (OLTP) and is fully transactional is designed as an easy to use all-in-one
both across the database and throughout database, striving to minimize the need for
the cluster. Features include high avail- third party applications, tools, or support.
ability, high performance, zero adminis-
tration and self-optimization, resulting in MongoDB is offered since 2009 as an
a database system trusted and employed open source database. MongoDB takes its
by a global client base including Fortune name from “humongous”, referring to its
100 companies spanning several conti- intended usage for storing large amount
nents. RavenDB is deployed in a variety of of data. MongoDB is used in applications
systems both on-prem and in the cloud ranging from simple TODO apps to critical
using the RavenDB Cloud DBaaS Managed business systems and is widely used and
Service starting from simple single server known in the Non-Relational community.
deployments to geo distributed clusters, They became fully transactional in 2018.

2
RavenDB vs MongoDB

1. Maintaining Data RavenDB has been transactional for over

Integrity a decade, finding ways to constantly im-


prove your performance within the ACID
framework so you don’t have to pay with
How well does each database performance for greater data integrity.
preserve data integrity,
preventing data corruption or MongoDB became a transactional data-
base in 2018.
loss?
After 10 years of being ACID only over a
RavenDB is a fully transactional non-re- single document, MongoDB announced
lational database. It supports ACID trans- its ACID compliance over multiple docu-
actions both throughout your database and ments. Their challenge will be to improve
across your database cluster so your data is upon their new ACID guarantees without
safe. You can modify multiple documents sacrificing performance. Going ACID with
in a single transaction and be assured that MongoDB comes with performance costs.
all changes will be persisted to disk or all of
them will be rolled back.
2. Querying
RavenDB can ensure that your transaction & Aggregating Data
boundaries will be kept even when the data
is replicated among the different nodes in a
cluster. Transactions can be configured to How fast can you query data?
span the whole cluster for strong consis- How do you get aggregation
tency or use mutli-master mode for high results?
availability.

This is very helpful for hybrid solutions All queries made with RavenDB will always
using a document database in conjunction use an index. You never have to fear a table
with a relational SQL solution. You can scan or an unoptimized query plan grind-
maintain ACIDity throughout your current ing your business to a halt.
data architecture while enjoying the ability
to rapidly scale up with a Non-Relational When you make a query, the query opti-
solution. You can enjoy the speed, agility, mizer will recognize when a query cannot
and performance of a Document Database be answered using an index and will update
solution while keeping the data guarantees the database index configuration on the
of the traditional database model. fly. As you make more queries, you are
feeding the query optimizer to make better
decisions to retrieve your data. Over time,
the query optimizer will be able to produce

3
the exact set of indexes that you need in define indexes ahead of time, queries will
order to answer your queries quickly and scan the entire database and filter results
efficiently. on document each time.

You don’t need to have a highly trained ad- This typically results in acceptable perfor-
ministrator constantly monitor and adjust mance initially, with small datasets, but
the database indexes to achieve great per- quickly causes performance deterioration
formance. RavenDB is already doing that as the size of the data grows. Creating in-
for you. dexes ahead of time resolves this issue, but
creating indexes after the fact is a complex
This is most noticeable when you consider and delicate process.
aggregation queries, which are handled
using RavenDB’s native MapReduce fea- Indexing in MongoDB is single purpose.
tures. When an aggregation query is sent If you indexed the fields LastName and
to RavenDB, the query optimizer will cre- First name and you need to search by the
ate a MapReduce index to answer it if one FirstName and LastName prefix, you’ll
doesn’t exist already. need a new index.

Latency is obliterated as query results come For aggregation support, MongoDB pro-
faster because RavenDB is not required to vides both MapReduce queries and aggre-
comb your database all the time for results. gation pipeline queries. These are more
Once an index is set up, query times drop complex than simply using a GROUP BY
by over 99.9%, using precomputed results statement, with MapReduce being more
that are kept current for you behind the flexible and the aggregation pipeline being
scenes. This not only saves you time, on faster. In both cases, MongoDB needs to
the cloud it saves you money. evaluate all the matching documents and
then compute the final total. This happens
Aggregation queries in RavenDB are very on every query, resulting in workarounds
cheap and require almost no work from such as spilling the results of a query to a
developers or admins to get things work- temporary collection and refreshing that
ing. As a native part of RavenDB, you do not on a routine schedule.
need third party components to perform
aggregates. In such cases, you need to schedule re-
freshing the results during off hours and
MongoDB supports dynamic queries, but it manage it all manually. You need to spend
has no concept of auto indexing or learning time and effort about the freshness of the
from production usage profiles. As such, results and the cost of refreshing the query.
unless the administrator has taken steps to

4
RavenDB vs MongoDB

How much “new stuff” do you If you have any experience with SQL, you
need to learn in order to query can understand the RQL syntax easily.
each database? Learning to write queries in RQL with
knowledge of SQL is like being a tennis pro
and having to learn racquetball.
RavenDB uses the Raven Query Language
(RQL) for queries. RQL is the SQL of the MongoDB supports queries using
Document Database. Like SQL, it is built JavaScript and JSON based query objects.
to be user friendly for developers and This is powerful, but can be unfriendly if
non-developers alike. RQL gives you an you aren’t a developer familiar with both
intuitive way to query the database, proj- MongoDB and JavaScript.
ect results, and work with documents in
RavenDB. Let’s use a simple query to aggregate
results from a collection of Zip Code sta-
tistical data and get the states that have
more than 10 million residents and their
population.

Here is how you would need to write your query using SQL, RavenDB, and MongoDB:

SQL:

SELECT State, SUM(Population) AS TotalPop


FROM ZipCodes
GROUP BY State
HAVING TotalPop >= (10*1000*1000)

RQL (RavenDB Query Language):

FROM ZipCodes
GROUP BY State
WHERE SUM(Population) >= 10_000_000
SELECT SUM(Population) AS TotalPopulation, State

5
MongoDB Syntax:

db.zipcodes.aggregate( [
{ $group: { _id: „$state”, totalPop: { $sum: „$pop” } } },
{ $match: { totalPop: { $gte: 10*1000*1000 } } }
] )

Source: http://bit.ly/2yurvZw

With MonogDB, you need to have a DBA go over all queries and ensure that they don’t put too
much load on the server. You also need to define indexes ahead of time and re-validate your
configuration on each deployment of your software.

All of this is handled automatically by RavenDB behind the scenes, as part of the notion that
you should have as close to a zero-admin unattended database experience as possible in your
application stack.

both database and clusterwide. In its latest


3. Performance version, RavenDB has overhauled most of
the database and introduced significant
How fast can each database performance improvements to make han-
process your data? How well dling Big Data a small challenge. Using
does each handle Enterprise RavenDB on the cloud whether in your own
cloud, as a service with RavenDB Cloud, or
Level load?
in a hybrid architecture will save you time,
resources, and money.
RavenDB is able to reach over 150,000
writes per second per node on commod- Voron, RavenDB’s tailor made Persistent
ity hardware (machines selling for less Key/Value storage engine was built from
than $1,000), and exceeds 1 million reads the ground up specifically for RavenDB
per second with sustained low latency 4.0. When a new feature comes out for
throughput. RavenDB enjoys single digit RavenDB, the resources that support it
millisecond performance right up until you are managed by the same team, making it
hit the limits of your hardware. easier to identify and build the optimal set
of tools. We aim to localize the number of
The RavenDB team keeps improving the components and tools available to you in
database’s performance from version to one place, making RavenDB as easy and
version, sustaining its rich and complex powerful to use as possible.
functionality along with ACID guarantees

6
RavenDB vs MongoDB

The standard performance test for RavenDB team developed the blittable format to
is to load the entire Stack Overflow dataset. allow processing documents efficiently. To
This includes tens of millions of questions make this happen, we restructured how
totaling over 50 GB of data. Using RavenDB, we save things to memory and to disk to
it currently takes less than five minutes to make the process of reading a document
load, and our team keeps improving the dirt cheap. This is one of the advantages
performance. of creating an all in one database where
every component is custom made to work
MongoDB supports CRUD operations, in tandem with one another to maximize
simple updates, simple indexing, and both performance.
simple and aggregate queries at peak per-
formance speeds, just like RavenDB. For The blittable format allows RavenDB to
non-concurrent, plain write oriented tasks avoid deserialization of JSON objects when
with no indexing MongoDB is typically reading them from persistent storage. This
faster. saves lots of memory and CPU – especially
on the cloud. Blittable can process data
However, there are many operations that without having to first parse the entire
MongoDB does not support: Pre-computed document into its object form. This reduc-
map-reduce operations, complex patch es the costs of most operations in RavenDB
operations, and non-trivial indexes and significantly. The blittable format was de-
queries. As the features you will need be- signed to take advantage of the way Voron
come more advanced, the performance works to streamline document processing
costs in MongoDB rise significantly. and significantly simplify the amount of
work RavenDB needs to do.
MongoDB lags behind RavenDB in
performance for aggregation queries, For example, instead of writing our own
transactions support, and real data integ- caching subsystems, RavenDB was de-
rity. RavenDB is also able to handle all your signed to take advantage of the operating
writes in a transactional manner with a system’s own page cache and access doc-
speed that can match your needs. uments in such a way as to make optimal
usage of the kernel’s behavior. The kernel
has more information about the state of
How does each database’s the whole system, which allows RavenDB
processing method push to be a better team player and share the
performance to the max? resources of the system, instead of hogging
them all.

The RavenDB native format is called blitta- MongoDB uses a format called BSON
ble JSON, a zero-overhead format for stor- (Binary JSON) to store documents.
ing and processing JSON data. The RavenDB Processing BSON is somewhat easier for a

7
computer than processing of JSON textual nodes will replicate the most current state
data, but it is still a format that requires of data to it, keeping your information
deserializing documents whenever you highly available with multiple copies.
load them, increasing both memory and
CPU usage. When running in a cluster, RavenDB uses
the multi-master model. When you make a
RavenDB’s blittable format means that write to any node in the cluster, that write
it can just access the documents direct- will be accepted and then replicated to the
ly in the operating system’s page cache, rest of the cluster. RavenDB’s multi-mas-
MongoDB uses a separate cache (in addi- ter node handles failure more gracefully
tion to the page cache) and needs to dese- because each node writes independently of
rialize the BSON documents whenever it the rest of the cluster and there is no period
accesses them. of unavailability if the leader of the cluster
fails.

4. Scaling Out Your RavenDB also has a monitoring dashboard

Database that highlights nodes that have gone down,


and tells you what the root cause of the
problem is, enabling you to perform main-
How does each database tenance on your system faster and more
maintain high-availability? efficiently.  Assignment failover makes
sure that all outstanding tasks assigned to
a downed node are evenly redistributed to
RavenDB makes it easy to set up a cluster the working nodes in your cluster.
of multiple servers to act as nodes for your
database. As part of your free license, you MongoDB has a slew of processes with dif-
can set up a cluster with up to 3 nodes. ferent purposes that you need to calibrate
Setting up a cluster is as simple as point and on your own to set up a cluster which will
click in the RavenDB studio, and it’s even maintain high availability for the database.
easier with RavenDB Cloud, our Database You have to configure the servers, query
as a Service. The cluster takes care of all the routers, and shards. This increases the
details of replicating data between nodes, deployment and management complexity
ensuring sufficient copies of your data of the cluster. In some cases, to reconfigure
are kept, and dynamic load balancing and settings in your cluster, you have to shut
failover between the nodes in the cluster. down every node and individually reset the
settings.
If one node failed, other nodes will contin-
ue to operate and your users will have con- MongoDB uses the master-slave replica-
tinuous access to your database. Once the tion process where the data is written to a
faulted node is up again, one of the other single node and then that node will write

8
RavenDB vs MongoDB

to the other nodes in the cluster. This RavenDB packages everything in a


can create a single chokepoint in the data well-defined and easy to use location, with
architecture and a node failure can stall all operations available both as scriptable
the entire system while a different node is commands and as part of a world class GUI.
selected as the new master.
This is great for smaller businesses with
To replicate, MongoDB uses the OpLog. a limited supply of developers and time
It receives the operations needed to be available for IT. For large organizations,
executed by the slave nodes in order to a complete solution will ensure that best
replicate the data to the master state. If a practices are followed and a consistent and
failure occurs and there are enough writes verifiable approach is used throughout.
to fill the OpLog, this can put your cluster This is ideal for the cloud where every ad-
into a permanently bad state and require don can cost you money for every moment
an admin intervention to recover. you are using it.

MongoDB is more like a do it yourself


5. Features solution. You’ll need to purchase or find a
MongoDB Admin GUI and you need to get
How many third-party a BSON utility library to deal with every-
applications and plugins will you thing BSON. For more interesting queries,
have to install along with each you’ll usually need to include Apache Solr
or ElasticSearch on top of a MongoDB da-
database?
tabase since it has limited support for full
text search.
RavenDB is a synergy of tailored compo-
nents developed in-house to serve all your There are about a dozen tools that are pro-
data needs in one place. RavenDB strives vided with just the MongoDB installation
to minimize cost and complexity by mak- alone. For things like shell and backup and
ing your database the only component. restore tooling, there are several dozens of
Features that you would usually have to components for these tools. The number of
plug in from someplace else like fast ag- tools that you are required to compose to
gregation, Graphical User Interface (GUI), perform certain operations with MongoDB
ETL and Pull replication, full text search, can be overwhelming, making it difficult to
memory management are already part of figure out the best approach to use in a giv-
your RavenDB database and your RavenDB en situation, and what you have available
Cloud instance. The RavenDB API includes to perform a specific task.
caching, best practices and design patterns
like identity map and unit of work.

9
6. Integration With Your RavenDB also has pull replication, enabling

Organization’s Current you to replicate from one location to widely


distributed nodes with ease. A common use
Systems case for pull replication is when you have
a database on the cloud replicating to a set
of RavenDB instances located on the edge.
How well does each Non- RavenDB is used as the synchronization
Relational database work with mechanism for your data, allowing you
SQL relational databases and to handle operations locally (and work in
a disconnected mode) while still getting
the cloud to support hybrid data
updates and sharing data with the global
architectures?
database.

RavenDB supports automatic ETL (extract, MongoDB has “connectors” that support
transform, load) processes to relational pulling data into a relational database. The
databases, other nonrelational databases, Mongo BI connector translates SQL queries
and databases on all cloud platforms. You into MongoDB queries, and returns it to
don’t need an outside application, it’s a its BI systems. MongoDB does not support
core part of RavenDB. a “push” oriented service that transfers
data to a relational database for OLAP and
You can take the documents in your Non- reporting purposes.
Relational RavenDB Database and replicate
them to a relational SQL database. This en-
ables you to perform a wide variety of anal- 7. Caching And
ysis and reporting on your data in a familiar Concurrency
setting, using your existing reporting tool-
set. A common deployment pattern is to
introduce RavenDB as a write behind cache How does each database cache
to a relational database. Another common it’s data?
deployment is to use RavenDB as part of a
polyglot microservices architecture.
RavenDB includes both automatic and
RavenDB also has an SQL migration wizard aggressive caching. RavenDB clients can
where it takes your relational data and cre- cache data locally and let the server know
ates a basic document template to collect that they have a cached version of the
it. It’s a starting point to take in data from query they are making. An optimized code
your relational database and enable you to path inside RavenDB then checks whenever
model it in nonrelational form. there have been any modifications to the
query. If there haven’t been, the client will
then use the cached version, saving himself
an additional trip to the server.

10
RavenDB vs MongoDB

This allows RavenDB to save a lot of band- a single roundtrip trip to the disk, signifi-
width and cost, since many queries do cantly reducing I/O costs and improving
not change very often, and can be served performance by large margins.
completely from the client cache while
still being sure that you are always serving For reads, RavenDB scales up with direct
fresh information to the users. This saves relation to the number of cores available to
you massive amounts of latency, especially the system, since there is no need for locks
on the cloud. or other concurrency controls to waste cy-
cles on.
RavenDB supports aggressive caching.
Instead of the client asking the server if MongoDB uses multi-granularity locking.
something changed after every query, the Locks are handled at multiple levels (serv-
client will ask the server to let it know er, database, collection, and document)
when anything changes on the server and need to be managed by MongoDB to
side. Until it gets the notification, it can ensure proper behavior. Lock management
work purely from its own cache. RavenDB is typically expensive in databases, with
doesn’t just save you the query cost and locking & latching taking over 30% of the
the bandwidth transfer, but eliminates the overall cost. The number of the locks and
network roundtrip costs as well. their management can eat up significant
amounts of time when dealing with pro-
Automatic and aggressive caching are duction scale load.
also parts of the RavenDB Cloud (DBaaS)
Managed Service.
8. Data Security
MongoDB doesn’t have comparable fea-
tures to client integrated caching or ag- How does each database protect
gressive caching your data? How certain can
you be that nobody will hack
into your private information or
How does each database handle
destroy your reputation?
Concurrency?

RavenDB can encrypt information in tran-


RavenDB’s in-house storage engine Voron sit and at rest in your database. To safely
was built explicitly to increase perfor- guard your data on disk, RavenDB uses
mance as concurrency grows. It uses an the XChaCha20, with 256 bits encryption.
MVCC architecture to ensure that writers RavenDB uses x509 certificates for authen-
do not block readers and vice versa. With ticating access to your data, and TLS 1.2 for
concurrent writes, RavenDB is able to encrypting all communication between
merge multiple concurrent operations into clients and servers.

11
To let a developer start coding an applica- developers to quickly download their data-
tion quickly, you can download RavenDB base and start coding, the configuration is
and run it with just the no security, listen- set to consider every user of the database
ing only on the local loopback device. As as an administrator. This is effective in
long as the database is used inside the local allowing for developers to focus on build-
machine, you can usually ignore all secu- ing their application. However, once the
rity concerns (accepting no outside con- application goes beyond one local machine
nections), and require no authentication. and remote users are able to connect to the
If you set RavenDB to listen to connections database, it is easy to miss a step and forget
outside your local machine, but didn’t to lock the door.
setup security properly, your database will
immediately block the vulnerable con- The result was lost records, critical data
figuration and require the administrator held for ransom, and leakage of sensitive in-
to properly setup the security and access formation from many organizations.
control to prevent unauthorized access to
the data.
9. Cloud Solutions
RavenDB will not let you expose your data
outside your local machine until you have
adequately provided security for it. What Cloud solution does each
Database offer and how do they
RavenDB also makes it easy to set itself up save you time and money?
securely. You don’t have to jump through
hoops or go through reams of documen-
tation. A friendly wizard will take you RavenDB Cloud is a fully automated man-
through the process of setting up a secured aged cloud service (DBaaS) run by the
cluster of RavenDB according to our best same developers that built and maintain
practices. That, combined with proactive- the RavenDB database. RavenDB Cloud is
ly preventing vulnerable configurations, available on AWS and Azure in all regions.
ensures that your data isn’t left unsecured In minutes you can set up a fully functional
and available over the public Internet. RavenDB database with the RavenDB Cloud
development team handling your day to
To set up MongoDB securely is a complex day tasks like security, server provisioning,
process. Evidence suggests that there are database setup, backups, managing and
steps that are routinely skipped. MongoDB maintaining your database cluster, patch-
databases have been hijacked in multiple ing updates, and sustaining high-avail-
high-profile instances. Hackers wiped ability all behind the scenes.
out MongoDB client data and held their
business hostage by demanding money in RavenDB was originally designed to work
return for the restoration of their database. best for distributed applications. The cloud
MongoDB is not safe by default. To enable has turned all applications into distributed

12
RavenDB vs MongoDB

ones so RavenDB has been anticipating Development Clusters, the cluster size for
the needs of cloud applications even before new apps. Dedicated Production Clusters,
there was a cloud. Automatic and aggressive for big instances.
caching features slash latency and cost.

By including features that most databases 10. Getting Started


normally require you to add on, complex-
ity is minimized, and you need less tools, What do you get in the free
compute power, and additional provisioned version of each product?
infrastructure. RavenDB Cloud works to
keep costs predictable and minimal.
RavenDB gives you a free option for a cloud
RavenDB’s built in GUI and simple API instance or an on-prem license.
lets you focus more of your resources on
building up your applications and less You can take out a free cloud instance
time working with the database. Scale your and start using RavenDB within minutes.
instances as your business grows. Deploy RavenDB will handle all of the back-end
your clusters in multiple locations to in- operations and enable you to focus exclu-
crease availability and performance for sively on how your data works to enhance
your users. your application. You can take a free in-
stance at: https://cloud.ravendb.net/
RavenDB Cloud is available in a free com-
munity instance, a development package, A free on-prem license includes 3 cores, 3
and a production tier. nodes, and 6 gigabytes of RAM memory for
your data. Your free license also includes
MongoDB Atlas is available on all major the RavenDB studio, giving you a GUI that
cloud platforms. Operational and secu- makes it easy to use. RavenDB has an easy
rity tasks are abstracted to their service. to use setup wizard that can get you started
Serverless functionality enables you to in minutes. You can take a free license at:
build your apps faster. MongoDB Atlas of- https://ravendb.net/free.
fers automated infrastructure provisioning,
database setup, maintenance, and patching MongoDB allows you to set up a cluster in
upgrades. their free version, but in order to use their
GUI studio, Monitoring tools, BI / ETL, you
There are three MongoDB Atlas clus- need to purchase the premium packages.
ter tiers: Shared Clusters, clusters of Many of their installation, configuration,
MongoDB instances that are shared with and maintenance processes are complex,
other MongoDB developers. Dedicated requiring tech support. MongoDB makes
money on support and subscriptions.

13
About RavenDB

For more information,


M entioned in both Gartner and
Forrester research, RavenDB is a pi-
oneer in NoSQL database technology with
contact us at

over 2 million downloads and thousands support@ravendb.net


of customers from startups to Fortune 100
Large Enterprises.

Over 1,000 businesses use RavenDB for


IoT, Big Data, Microservices Architecture,
fast performance, a distributed data net-
work, and everything you need to support
a modern application stack for today’s
user. For more information, please visit
ravendb.net or contact info@ravendb.net.

Documentation
https://ravendb.net/learn/docs-guide

Use Cases
https://ravendb.net/news/use-cases

Free Online Training


https://ravendb.net/learn/bootcamp

Webinars
https://ravendb.net/learn/webinars

RavenDB Download
https://ravendb.net/download

RavenDB Cloud Database as a Service


https://cloud.ravendb.net/

14
Houston • Buenos Aires • Hadera • Toruń
US Number: 1-817-886-2916
info@ravendb.net
© Hibernating Rhinos, Ltd. All rights reserved.

Оценить