简体   繁体   English

如何处理非常大的数据库,不要错过性能?

[英]How can I handle a very large database and do not miss the performance?

if i want to develop an application, I'm worried about its performance after the number of users and stored data increases. 如果我想开发一个应用程序,我会担心在用户数量和存储数据增加后的性能 actually I don't know what is the best way to implement a program that it works with a really large data and do some things like search in it, find and receive user information, search text and so on in real time without any delay ! 实际上我不知道实现一个程序的最佳方法是什么,它适用于非常大的数据,并做一些事情,如搜索,实时查找和接收用户信息,搜索文本等,没有任何延迟

Let's me explain the problem more 让我来解释一下这个问题

for example i have chosen ' Mongodb ' as a database and suppose we have at least five million users and a user want to log in into the system, the user has sent the username and password 例如我选择' Mongodb '作为数据库并假设我们至少有500万用户并且用户想要登录系统,用户已经发送了用户名和密码
The first thing that we should do is to find the user with that username and then check the password, in mongodb we should use something like 'find' method to get the user's information, something like below: 我们应该做的第一件事是找到具有该用户名的用户然后检查密码,在mongodb中我们应该使用类似'find'的方法来获取用户的信息,如下所示:

Users.find({ username: entered_username })

then get the user information and we check the password but the 'find' method should search the username between million users and it's a large number and if any person request for authentication, this method should be run for each of them and it cause a heavy processing on the system 然后获取用户信息,我们检查密码,但'find'方法应搜索 百万用户之间的用户名,这是一个很大的数字,如果任何人请求身份验证,应该为每个用户运行此方法,这会导致重处理系统

but unfortunately this problem is only for something like finding a user, if we decide to search a text when we have a lot of texts and posts on the database the problem is more bigger 但遗憾的是,这个问题只适用于寻找用户之类的问题,如果我们决定搜索文本,当我们在数据库上有大量文本和帖子时问题就更大了

i don't know how big companies like facebook and linkedin search through millions of data in such a short span of time. 我不知道像facebook和linkedin这样的大公司在如此短的时间内搜索了数百万的数据。 actually i don't want to create something like facebook or more but i have a large amount of data and i'm looking for a good way to handle it 实际上我不想创建像Facebook或更多的东西,但我有大量的数据,我正在寻找一个很好的方法来处理它

is there any framework or something else that help me to handle large data on the databases or is there exist a method to implement data on database so that we search and find data fast and quickly? 是否有任何框架或其他东西可以帮助我处理数据库上的大数据,或者是否存在一种在数据库上实现数据的方法,以便我们快速,快速地搜索和查找数据? should i use a particular data structure? 我应该使用特定的数据结构吗?

i founded an opensource project elasticsearch that it help us to search faster but i don't know if i found something with elastic how can i find it on mongodb too for doing something like updating data and if i use elastic search i should use mongodb too or not!? 我创建了一个开源项目elasticsearch ,它帮助我们更快地搜索,但我不知道我是否找到了有弹性的东西我怎么能在mongodb上找到它来做更新数据的事情,如果我使用弹性搜索我也应该使用mongodb或不!? can i use elastic as a database and as a search engine simultaneous !? 我可以同时使用弹性作为数据库和搜索引擎!
if i use elasticsearch and mongodb together then i should have two copies of my data, one in mongodb and one in elasticsearch!? 如果我一起使用elasticsearch和mongodb,那么我应该有两份我的数据,一份在mongodb,一份在elasticsearch中! and this two copies of the data that are separated :( i wish elasticsearch search in the mongodb that does not have to create two copies of the data 和这两个分开的数据副本:(我希望在mongodb中搜索弹性搜索,不必创建两个数据副本

thank you if you help me to find out a good way and understand what should i do. 谢谢你,如果你帮我找到一个好方法,并了解我该怎么做。

When you talk about performance, it usually boils down to three things: 当你谈到性能时,它通常归结为三件事:

  • Your design 你的设计
  • Your definition of "quick", and 你对“快速”的定义,以及
  • How much you're willing to pay 你愿意支付多少钱

Your design 你的设计

MongoDB is great if you want to iterate on your data model, can scale horizontally, and very quick if used properly. MongoDB非常棒,如果你想迭代数据模型,可以水平扩展,如果使用得当,速度非常快。 Elasticsearch on the other hand, is not a database. 另一方面,Elasticsearch不是数据库。 However, it is very quick for searching. 但是,搜索速度非常快。 A traditional relational database will be useful if you know exactly how your data looks like, and don't expect it to change much, or is relational by nature. 如果您确切地知道数据的外观,并且不希望它发生太大变化,或者本质上是关系型的,那么传统的关系数据库将非常有用。

You can, for example, use a relational database for user login, use MongoDB for everything else, and use Elastic for textual, searchable data. 例如,您可以使用关系数据库进行用户登录,将MongoDB用于其他所有内容,并将Elastic用于文本可搜索数据。 There is no rule that tells you to keep everything within a single database. 没有规则告诉您将所有内容保存在单个数据库中。

Make sure you understand indexing, and know how to utilize it to its fullest potential. 确保您了解索引,并知道如何充分利用它。 The fastest hardware will not help you if you don't design your database properly. 如果您没有正确设计数据库,最快的硬件将无法帮助您。

Conclusion: use any tool you need, combine if necessary, but understand their strengths and weaknesses. 结论:使用您需要的任何工具,必要时组合,但要了解它们的优点和缺点。

Your definition of "quick" 你对“快”的定义

How "quick" is quick enough for your application? “快速”如何快速适合您的应用程序? Is 100ms quick enough? 100毫秒足够快? Is 10ms quick enough? 10毫秒足够快吗? Remember that more performance you ask of the machine, more expensive it will be. 请记住,您对机器的性能要求越高,它就会越贵。 You can get more performance with a better design, but design can only go so far. 您可以通过更好的设计获得更多性能,但设计只能到目前为止。

Usually this boils down to what is acceptable for you and your client. 通常这归结为您和您的客户可接受的内容。 Not every application needs a sub-10ms response time. 并非每个应用程序都需要低于10毫秒的响应时间。 There's plenty of applications that can tolerate queries that return in seconds. 有很多应用程序可以容忍在几秒钟内返回的查询。

Conclusion: determine what is acceptable, and design accordingly. 结论:确定什么是可接受的,并进行相应的设计。

How much you're willing to pay 你愿意支付多少钱

Of course, it all depends on how much you're willing to pay for all the hardware that need to host all that stuff. 当然,这一切都取决于你愿意为所有需要托管所有东西的硬件支付多少钱。 MongoDB might be open source, but you need some place to host it. MongoDB可能是开源的,但你需要一些地方来托管它。 Also, you cannot expect magic. 此外,你不能指望魔术。 You can't throw thousands of queries and updates per second, and expect it to be blazing fast when you only give it 1 GB of RAM. 您不能每秒丢弃数千个查询和更新,并且当您只给它1 GB的RAM时,它会非常快速。

Conclusion: never under-provision to save money if you want your application to be successful. 结论:如果您希望您的应用程序成功,从不低于节省资金。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在基于 webpack-react-node 的网站中处理非常大的数据(100000 个 javascript 对象)? - How do I handle very large data (100000 javascript objects) in webpack-react-node based website? Mongodb Import非常慢,如何提高性能? - Mongodb Import is very slow, how can I improve the performance? 如何在数据库中存储大列表 - How can I store a large list in a database 如何提高 Mongoose/MongoDB 创建和更新大量条目的性能 - How can I increase Mongoose/MongoDB create and update performance for a large number of entries 我应该保持数据库连接打开以处理每个请求吗? 以及如何以正确的方式做到这一点 - Should I keep a database connection open to handle every request? And how to do that in the right way 如何在非常大的数据库上使用mongodb查询操作(每个分片有3个大约260-3亿) - How to use mongodb query operation on a very large database (have 3 shards of around 260-300 million in each) 大规模数据库性能…MongoDB / NoSQL eval - Large scale database performance … MongoDB / NoSQL eval 如何处理大型mongodb集合 - How to handle large mongodb collection 如何处理Elasticsearch中包含“ _”的字段? - How do I handle fields in elasticsearch that contain a '_'? 我如何处理MongoDB中的大数组? - How do I handle big arrays in MongoDB?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM