Saving data in real time in 1000 files

I have a program that receives real-time data on 1000 topics. It receives - on average - 5,000 messages per second. Each message consists of two lines, a subject and a message value. I would like to save these lines along with a timestamp indicating the arrival time of the message.

I use 32-bit Windows XP for hardware and programming the Core 2 core in C #.

I would like to save this data in 1000 files - one for each topic. I know that many people will want to tell me to save the data in the database, but I do not want to go this way.

I reviewed several approaches:

1) Open 1000 files and write them to each when data arrives. I have two problems. I don’t know if 1000 files can be opened at the same time, and I don’t know what effect this will have on disk fragmentation.

2) Write to one file and - somehow - process it later to produce 1000 files.

3) Keep everything in RAM until the end of the day, and then write one file at a time. I think this will work well if I have enough bar, although I may need to switch to 64 bits to overcome the 2 GB limit.

How do you approach this problem?

+3
source share
11 answers

, : 1000 , /. , , . , , . , , . . , , . , , , ( , N ) . , , .

+2

, . . .

, , , , , .

. .

: , , , .

, .

+10

n8wrl, . ...

: -)

. , ( , ) .

(, Count). , , , .

. , , , ( (, streamWriter) ..).

, ... , (id, , , ), , .

+4

, - ! ...

  • 1000 . - O/S .
  • db-ish-ness! , .
  • RAM = volatile. 17:00.

? DB! , .. ..

:)

+2

! 5000 / 2kb = 10 /. - 600 . , . .

: ​​. , .

+2

, PI. , PI .

, . . , , . , - MSMQ ( MS), .

db . db, , , - , SQL 5000 . , 10000 , .

:

~ 50 → small datetime = 4bytes + (~ 10 unicode) = 10bytes + Message → 31characters (non unicode) = 31 bytes.

50 * 5000 = 244kb/sec → 14mb/min → 858mb/hour

+2

, ?

, ​​ sqlite:

SQLite - , , , , SQL. SQLite - SQL- . SQLite .

+2

2 : , , , . , . , , .

+1

. - PI Wonderware Data Historian. MS SQL, ( , ). API, , , SQL.

, 2 , .

, , , .

, , 5 x 60 x 60 x 24 = 432000 , , , , . , , - , MS SQL Enterprise Edition - . , , .

, , .

+1

1000 .

+1

( , , ), , , , /, 1000 . X , , , 15 , 1000 .

All this asks the question of why there is no database, and why you need 1000 different files - you may have a very good reason - but again, perhaps you should think about your strategy and make sure that it sounds reasonable before you go further down this path.

0
source

Source: https://habr.com/ru/post/1709378/


All Articles