[英]Multi Connections to DB
I have a project where at pick times the site will get 1000 calls per secs this calls need to be saved in the DB ( MS-SQL DB ) . 我有一个项目,在挑倍的网站将获得每秒这个电话需要在数据库(MS-SQL数据库)来保存1000所调用。
What is the best practice to manage this large scale connections. 管理此大规模连接的最佳实践是什么。
I am using .net C# . 我正在使用.net C#。 Currently building this as a site that get all the calls in post way.
当前将此网站构建为可以通过邮局获得所有电话的网站。
Thanks For your answers. 感谢您的回答。
From my experience the fastest way to insert a large amount of data is to use a GUID
as PK
. 根据我的经验,插入大量数据的最快方法是使用
GUID
作为PK
。 If you use an autoincrement the sql will write the rows one by one to get the next ID. 如果您使用自动增量,则sql会逐行写入行以获取下一个ID。 But if there is a
GUID
, the server will write all your data at the "same" time. 但是,如果有
GUID
,服务器将在“相同”时间写入所有数据。
Depending on the ressources of your production machine there are several approaches: 根据生产机器的资源,有几种方法:
1fst: Store all the requests in one big list and your application writes all the requests synchronously into your database. 1fst:将所有请求存储在一个大列表中,然后您的应用程序将所有请求同步写入数据库。 Pro: pretty easy to code, Con: could be a real bottleneck
优点:很容易编写代码,缺点:可能是一个真正的瓶颈
2nd: Store all the requests in one big list and your application starts a thread for every 1000 requests that you received, these threads write the data into your database asynchronously. 第二个:将所有请求存储在一个大列表中,并且您的应用程序针对收到的每1000个请求启动一个线程,这些线程将数据异步写入数据库中。 Pro: Should be faster, Con: hard to code and hard to maintain.
优点:应该更快;缺点:难以编写代码且难以维护。
3rd: Store the request inside the memory of the server and write the data into the database when the application is not busy. 第三:将请求存储在服务器的内存中,并在应用程序不忙时将数据写入数据库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.