Use lock tables before counting. And unlock it after inserting.
Or you could use GET_LOCK then RELEASE_LOCK. With this you do not need to lock all entry table.
Or explore theme about gap locking for innodb tables. With this you need to use transactions.
And you could use jMeter for testing your queries.