I have a http handler and I m storing every request to a concurrent queue collection in the memory. after a certain time, i m bulk inserting the collection to a database.
is this a bad idea? Because there is high volume, this seems to be a better approach IMO.
I do see some discrepancies (Number of hits vs number of stored elements in the db), due to threading, while i m flushing the concurrent collection, i m locking it and bulk insert its content and then empty the collection. then remove the lock from collection.
is there a better practice? or have you done a similar thing?
Sorry but I would say that it is a bad idea. There are the following problems:
We have written web applications that write 1000 rows per second to an SQL Server database at peak load.
Try writting your application as simple as possible first and then performance test it.
The speed at which you can insert into the database depends alot on your hardware, but there are also things that you can do in your program:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With