Cara menggunakan mongodb vs elasticsearch performance

There are various databases to store data, such as Elasticsearch, Oracle, Postgres, MongoDB, and MySQL, etc. Elasticsearch and MongoDB are popular document-oriented database. Both are distributed and highly scalable datastores. Both databases offer backup and recovery facilities. Along with some common features, they also have some differences that make them different from each other. Therefore, it is very important to understand the difference between them.

What is Elasticsearch?

Elasticsearch is a NoSQL database that is used to store data in document form. It is an open-source search engine. Many well-known companies, such as - Accenture, Linkedin, and OpenStack, use Elasticsearch. It is developed in Java and top of the Apache Lucene. Elasticsearch is a real-time analysis engine designed for storing logs. Elasticsearch is a best choice in case when an application that requires too many filters or search operations.

What is MongoDB?

MongoDB is document-oriented NoSQL database. It works on the concept of document and collection. It is a schema-less database that is written in C++. MongoDB supports dynamic query on documents. As MongoDB is a NoSQL data, it uses dynamic schema for documents. MongoDB is able to handle the JSON document and allows the binary conversion of the JSON document. It can convert the JSON into BSON (Binary version of JSON). BSON is nothing but a binary version of JSON, which is similar to it.

Semakin berkembangnya teknologi, jumlah informasi yang diproduksi oleh organisasi semakin meluap, baik organisasi bisnis, maupun pemerintahan. Hal ini juga terjadi pada social network. Salah satu social network terpopuler, Facebook, memiliki milyaran anggota aktif yang menghasilkan jutaan data per harinya. Fenomena ini menimbulkan kebutuhan akan teknologi yang mampu menangani pengolahan data dalam jumlah besar dalam waktu yang singkat. Beberapa social network seperti LinkedIn dan Facebook ‘pun telah menggunakan NoSQL sebagai solusi beberapa fiturnya. MongoDB dan Elasticsearch adalah salah satu basis data NoSQL berorientasi dokumen. Namun keduanya memiliki struktur data yang berbeda. Elasticsearch memiliki struktur data inverted index untuk mendukung fungsinya sebagai mesin pencari. Sedangkan MongoDB menggunakan struktur index berbentuk B-Tree yang sebelumnya banyak digunakan oleh RDBMS. Penelitian ini bermaksud untuk meneliti pengaruh struktur index pada basis data NoSQL Elasticsearch dan MongoDB terhadap kinerja waktu dalam pengembangan aplikasi web social network. Eksperimen dilakukan dengan menjalankan fitur post untuk menguji kinerja penulisan, profil anggota untuk menguji kinerja pembacaan, dan pencarian anggota dan post untuk menguji kinerja pencarian secara full-text. Eksperimen fitur post dan fitur profil anggota dilakukan dengan penambahan beban virtual user dan jumlah data post. Sedangkan eksperimen pada fitur pencarian dilakukan dengan penambahan jumlah data post dan jumlah kata kunci yang dicari. Hasil eksperimen ketiga fitur menunjukkan bahwa Elasticsearch memiliki kinerja waktu yang lebih unggul pada dua fitur dibandingkan MongoDB, yaitu pada fitur profil anggota dan pencarian. Artinya, MongoDB unggul untuk penulisan data yang banyak. Hal ini disebabkan oleh struktur index Elasticsearch yang membutuhkan serangkaian proses analisa ketika data disimpan sehingga berdampak pada kinerja waktu. Namun, serangkaian proses analisa tersebut mengakibatkan proses pembacaan dan pencarian menjadi jauh lebih cepat walaupun jumlah data post terus bertambah. Kata kunci: Social Network, NoSQL, Orientasi Dokumen, MongoDB, Elasticsearch.

Ringkasan Alternatif

The vast growing of technology affects the amount of information produced by organizations, both business organizations and governmental. This also happens on social network. One of the most popular social network, Facebook, has billions of active users that produce millions of data every day. This phenomenon creates the need of a technology that is capable of handling huge amount of data in a short time. Some of social network, such as LinkedIn and Facebook, have already used NoSQL as the solution for some of their features. MongoDB and Elasticsearch are one of document-oriented NoSQL databases. However, each of them has different data structure. Elasticsearch uses inverted index as data structure to support its main function as search engine. Meanwhile, data structure used by MongoDB is in the form of B-Tree that many RDBMS are using today. This research is performed to determine the influence of index structure of NoSQL database Elasticsearch and MongoDB on time performance in developing social network web application. Experiment is performed by running post feature in order to examine the write performance, running profile feature in order to examine the read performance, and running search feature in order to examine the full-text search performace. Experiment on post and profile feature are conducted with the increase of virtual user and the amount of post data. While experiment on search feature is conducted with the increase of the amount of keyword and post data. The result of these experiments shows that Elasticsearch is faster in two of the three features experimented compared to MongoDB. The two features are profile and search features. In other words, MongoDB is faster in writing big amount of data, while Elasticsearch is faster in reading and searching. This happen due to the index structure of Elasticsearch that needs to go through additional analysis processes before writing data which affect the time performance. However, the processes also contribute in making both reading and searching features run fast even though the amount of data is huge. Keywords: Social Network, NoSQL, Document Oriented, MongoDB, Elasticsearch.