Here is an excellent presentation on how your application does IO. I have embedded the presentation from Ted Dziuba here:
From Session notes:
In this session, we will explore everything that goes on from when you call file.write() in your favorite programming language to when the data is finally written to disk. Heavily geared toward Linux programmers, this talk will cover a mix between hardware and software topics, the basics that every programmer who works with data should know. We’ll also take a look at some open source data storage packages – what they do right, and what they do horrifically wrong. We’ll also look into the persistent storage aspect of virtual machines such as Xen.
Attendees will walk away knowing some practical ways to optimize disk I/O intensive applications, through both hardware and software, as well as knowing how to work around some common traps that will rear their ugly heads at the worst possible times.