user635646
user635646

Reputation: 131

I/O , write to a file on a local drive or write to a socket , which one is faster?

I have a critical application (written in C) that is very performance sensitive. Writing things to log file will actually slow things down. I am considering to write the log messages to a socket, which gets send over to another application for logging. Would that work?

Upvotes: 2

Views: 112

Answers (2)

jgauffin
jgauffin

Reputation: 101150

Easiest way is to create a separate thread which takes care of the log writing. Just add all log entries to a linked list and let the thread work against that list.

Upvotes: 2

Puppy
Puppy

Reputation: 146910

Use asynchronous I/O. This will prevent your application from blocking.

Upvotes: 1

Related Questions