If you're inserting into a table in large dense bursts, it may need to take some time for housekeeping, e.g. to allocate more space for the table and indexes.
If don't want your app to wait, try using INSERT DELAYED though it does have its downsides.