Can tail slow down log writing speed on Linux (ext3)?
I'm wondering if tailf can generate blocking I/O which will slow down server responsiveness due to logging.
For ex. assuming the following setup:
Debian 5.1 linux server (foo) which is managed via terminal (foo is hosted on EC2).
Foo runs several applications, each writing to their own log file. For the sake of example, Apache httpd to /var/log/apache/access.log & Tomcat 5.5 to /var/log/tomcat5.5/myApp.log.
If I open an ssh connection to foo, (note: Internet link, high latency, relatively slow upload) and run tail -F /var/log/apache/access.log
can't I reach a situation where the kernel blocks httpd's writes to this log file and thus slows down httpd's performance because of the wait enforced on each thread?
To give some numbers, let's assume that foo logs ~200kb of log data per second which needs to be pushed over the wire to the ssh client.
Another theoretical aspect: What would happen if the /var/log file system set on an infinite size ram (remember: Theoretically speaking) so that the hard disk seek time is eliminated ?
Third aspect, what would happen if I'd open the ssh connection from a really slow link (Let's assume that foo is traffic shaped to push only 5kb/s upload)?
Would love to hear what you think guys.
Thanks for reading, Maxim.
Solution 1:
I don't think there will be some blocking over I/O here. When you do "tail -f", what's happening is
- your shell process, let's say bash, will spawn a new process 'tail'.
- tail will open the file, move file pointer to the end, wait for 3 seconds and check whether there are new data.
- if there is new data, tail will push it back to the bash using unix pipe.
- this data gets transmitted from server to your machine by bash + ssh.
So as you can see, a slow internet connection won't affect step #2, which is the key for I/O performance anyway.
Plus, tail opens file in 'read-only' mode and, an educated guess, logs are open in 'append-only' mode, so there shouldn't be much locking here to worry about. If this is still a bit concern for you, then you may want to try out the inotail which is based on latest linux inotify api to avoid polling the file.
Hope this helps, Alex