简体   繁体   中英

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 ) .

What is the best practice to manage this large scale connections.

I am using .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 . If you use an autoincrement the sql will write the rows one by one to get the next ID. But if there is a GUID , the server will write all your data at the "same" time.

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM