开发者

Reading a small file k times + small writes vs read large file k times + small appends

I have to make a decision for a script that shows the most recent event.

Each event can be less than 250 bytes.

There are two ways to do this

  1. Write to a file after every event. Read the file and output.
  2. Append to a file after every event. Read the entire file, find the last item, output. (the size of the file can grow pretty big, up to 1MB)

Assuming the reads are very frequent(up to once per second), writes are quite frequent (say arou开发者_如何学Gond 1000 times per day)

Which way is better for the hard drive?


Don't worry about it. Hard drives are cached (read and write).

Do what is simplest and the easiest to understand.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜