MySQL vs ElasticSearch vs MongoDB


Anfang des Jahres habe ich  mySQL und MongoDB  aus Sicht der Daten verglichen, jetzt geht es um Leistung. Neu im Bunde ist dieses Mal ElasticSearch, eine nicht-Datenbank, die sich vor allem mit schneller Volltextsuche rühmt, aber kann sie auch im Praxiseinsatz mithalten?


Earlier this year I compared mySQL and MongoDB from the perspective of data, now it comes to performance. New in the group is this time ElasticSearch, a non-database, which prides itself mainly with fast full-text search, but they can also keep up in practice?


今年早些时候,我从数据的角度考虑,比较了MySQL和MongoDB,现在有了一些成果。而且,在它俩中,加入了一个新成员:ElasticSearch,以快速的全文搜索能力著称。那么,在实践中,他们比较起来到底怎样呢?



mySQL dürfte die derzeit weltweit am weitesten verbreitete Datenbank sein. Einfach, schnell unkompliziert - zumindest für Kleinstapplikationen, damit lockt das Urgestein. Doch sobald es um mittlere Datenmengen, Performance, Skalierbarkeit oder Zuverlässigkeit geht, fangen die Probleme an.


mySQL is probably the currently most widely used database. Easy, quick simple - at least for micro applications, thus attracting the bedrock. But when it comes to medium-sized volumes of data, performance, scalability or reliability, the problems begin.


MySQL是目前使用最广泛的数据库,优点是简单、快捷,对于小型应用非常合适,所以吸引力很多用户。但是,当设计中等级别数据、性能、可靠性和可扩展性时,就会出现一些问题。


Mit ElasticSearch habe ich bisher kaum Berührungspunkte. Eingesetzt habe ich es noch nie, aber genau das soll sich aus aktuellem Anlass jetzt ändern. Sich selbst bezeichnet das Projekt nicht als Datenbank, sondern als hochperfomante Suchmaschine, vorzugsweise für die Volltextsuche. Warum es keine Datenbank ist, konnte mir bisher zwar niemand erklären, aber ich nehme diese Tatsache vorerst als gegeben hin.


With ElasticSearch I've barely touch points. Used I have never been, but that is about to change due to current events now. Described himself as not the project database, but as hochperfomante search engine, preferably for full text search. Why it is not a database, was able to get so far although nobody explain it, but I take this as a given fact for the time being.


对于ES我接触的比较少,过去几乎从来没用过,但是,因为目前的发展趋势,我的这种状况很可能发生改变。ES自我定义不是项目数据库,开始是是个搜索引擎的角色,很适合进行全文搜索。为什么它不是一个数据库呢,现在还没有一个合理的解释,但我准备把这作为一个既定事实了。


MongoDB hat sich schon vor drei Jahren im Vergleich gegen CouchDB und Postgresdurchgesetzt. ElasticSearch kommt mit einer großen Hypothek: Ich erwarte mir einen Performancevorteil gegenüber mySQL, der den zusätzlichen Hardware- und Entwicklungsaufwand rechtfertigt. Die aktuelle Beliebtheit einer Technologie war noch nie ein Qualitätskriterium, schon gar nicht für mich. MongoDB haben wir bereits im Unternehmenseinsatz, es soll zumindest die Chance bekommen, sich gegen die reine ElasticSearch zu behaupten.


MongoDB has prevailed in comparison to CouchDB and Postgres three years ago. ElasticSearch comes with a large mortgage: I expect a performance advantage over mySQL, which justifies the additional hardware and development effort. The current popularity of technology has never been a criterion of quality, certainly not for me. MongoDB we have for enterprise use, it should at least get a chance to compete with the pure ElasticSearch.


MongoDB与CouchDB相比具有优势,而且已经盛行3年了。ES具有一些先天优势,我希望它能够在竞争中战胜MySQL,因为MySQL更加依赖额外的硬件和开发工作。技术的当前流行程度并不是它们质量好坏的判别标准,尤其是对我来说。我们已经在企业级应用上使用MongoDB了,我认为它至少有和纯净版ES的竞争能力。


Real-World Test

实例测试


In meinem derzeitigen Hauptprojekt werden große Datenmengen verarbeitet (mittlerweile nennt man so etwas "BigData"). Millionen von Einzeldaten werden kombiniert, um am Ende ein Selektionsergebnis zu erhalten, dass schließlich die Datenbasis für zukünftige Abfragen weiter vergrößert. Genutzt wird diese Applikation von verschiedenen Anwendern mit unterschiedlichen Anforderungsprofilen. Die Performance ist seit Jahren ziemlich konstant, trotzdem gab es seitens der Nutzer den Wunsch nach einer Beschleunigung. Als Wunschziel wurden "20-50% der aktuellen Dauer einer Seketion" ausgegeben.


In my current main project large amounts of data are processed (now called something like "BigData"). Millions of individual data are combined to obtain at the end of a selection result that finally further increased the data base for future visits. Is used this application by different users with different requirement profiles. The performance is fairly constant for years, yet it was the part of the user's desire for an acceleration. As desired objective were "20-50% of the actual duration of a Seketion" output.


我现在的项目,在处理很多数据(人们喜欢称之为“大数据”),上百万的个人数据在进行筛选后,被进行合并处理,最后被添加到数据库中,方便以后的访问。数据是不同用户对应用的不同需求而产生的,应用软件的性能多年来保持稳定,虽然这也是因为用户的需求所促进的。数据存储目标预期是保存一个输出流程的20%-50%。

Die Software ist nicht optimal, hier gibt es definitiv noch Optimierungsmöglichkeiten, aber der mit großem Abstand größte Flaschenhals ist die genutzte mySQL-Datenbank: Die Selektionen sind nicht selten so aufwendig, dass ein kompletter Slave für Minuten, manchmal sogar Stunden blockiert ist. Die Nutzung von MyISAM ist dabei nicht gerade ein Vorteil, insbesondere in der Replikation, aber ein Wechsel zu InnoDB liegt außerhalb meines Entscheidungsspielraums - und selbst dann ist fraglich, wie weit sich die Performance steigern lassen würde.


The software is not optimal, there are definitely still possibilities for optimization, but the biggest by far bottleneck is used mySQL database: The selections are often so complicated that a complete slave for minutes, sometimes even hours is blocked. The use of MyISAM is not just an advantage, particularly in the replication, but a switch to InnoDB is beyond my powers of discretion - and even then it is questionable how far the performance would be increased.


这个软件不是最优的,还存在优化的可能,但它最大的瓶颈是是使用了MySQL数据库:选择往往很复杂,做完一次操作需要数分钟,有时候甚至是几个小时。使用MyISAM(MyISAM 是MySQL中默认的存储引擎)并不是一个优势,但是如果使用InnoDB(MySQL的数据库引擎之一)的话,我就更加无力吐槽了,所以软件的性能什么时候能得到提升是个值得深思的问题。


Das Datenmodell ist über Jahre gewachsen und auf die Datenerfassung hin optimiert. Das diese möglichst schnell läuft, hat höhere Priorität als mein Projekt und eine Änderung des Datenmodells würde sich auf viele andere Projekte auswirken.


The data model has grown over years and optimized for data collection towards. That this is running as fast as possible, has a higher priority than my project and a change in the data model would have an impact on many other projects.


数据建模已经发展了很多年了,目的是为了实现数据收集过程的优化。它的目的是使运行速度更快,数据模型中的一个改变比我的项目更加重要,因为它也可能对其它项目产生影响。


Für den Test nutze ich unsere Entwicklungsdatenbank: Knapp 300.000 Datensätze in der Haupttabelle mit unterschiedlich vielen Zusatzdaten in drei weiteren Tabellen. Diese vier Tabellen werden für die meisten Selektionen - nicht nur von meiner Applikation - genutzt, also typischerweise per JOIN mit der Haupttabelle verbunden.


For the test I use our development database: Nearly 300,000 records in the main table with different numbers of additional data in three other tables. These four tables are for most selections - not only from my application - used, so typically connected via JOIN with the main table.


在这个测试中,我使用了我们的数据库:主表里面有将近30万条数据,其它三个表中也有不同数目的额外数据。这四个表被用来做选择,而且表中数据不仅仅来自我开发的软件应用,所以通常通过JOIN和主表连接。


Die Testdaten kommen unseren Live-Daten in Struktur und Inhalt ziemlich nahe, sollten also ein realistisches Testszenario bilden.


The test data coming our live data in the structure and content fairly close, should therefore form a realistic test scenario.


测试数据和我们的现场数据结构和内容相近,因此可以模拟一个真实的场景。


Der Test soll hauptsächlich zeigen, wie gut sich alle drei Lösungen bei mehreren gleichzeitig laufenden komplexen Selektionen verhalten und ob hierbei ein Geschwindigkeitsgewinn erzielt werden kann. Aber zunächst geht es um die Installation und Befüllung der Testdatenbanken.


The test is primarily intended to show how well all three solutions behave when several concurrent complex selections and if this is a gain in speed can be achieved. But first, it comes to the installation and filling of the test databases.


这个实验是要是为了展现当遇到复杂索引时,三个数据库的性能表现,还有哪个数据库的检索速度稍微快一点。

首先需要把三个数据库安装上去。


Ich erwarte, dass mySQL weit abgeschlagen hinter ElasticSearch und MongoDB landen wird. Welche der beiden NoSQL-Technologien allerdings die Nase vorn haben wird, möchte ich nicht prognostizieren. Es würde mich weder überraschen, wenn MongoDB relativ weit hinter ElasticSearch bleibt, noch wenn die Datenbank die Suchmaschine deutlich schlägt - immerhin geht es hier um die Selektion mehrere Felder und nicht um eine Volltextsuche über den gesamten Datenbestand.


I expect that MySQL is far behind land behind ElasticSearch and MongoDB. What the nose will have the front of the NoSQL technologies, however, I do not want to predict. I would be surprised either if MongoDB is relatively far behind ElasticSearch, even if the database search engine clearly suggests - after all, it is about the selection multiple fields and not a full text search of the entire dataset.


我认为MySQL远远落后于ES和MongoDB,但是我不想预测哪项技术将在NoSQL中独领风骚。如果MongoDB真的落后于ES,我将很惊讶,尽管ES的搜索引擎不错,而且适合全文索引。


实验结果见下文:










可以从这个目录打开:

http://www.pal-blog.de/entwicklung/mysql-vs-elasticsearch-vs-mongodb.html


原文来自:

http://www.pal-blog.de/entwicklung/mysql-vs-elasticsearch-vs-mongodb.html


竟然是德语的,看不懂!硬着头皮看两段试试......

 果然还是看不懂,先谷歌翻译成英语再看吧......


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值