Helping in building fast, lightweight logic and data grab app

This is what my application needs to do

It will recieve mutliple http (posts/gets) from a seperate server (not sure if they will be sequintal)
It then needs to count how many previous http posts/get it has received from that server
Add one to that dynamic variable (the count of http requests) and using that number as a unique id, pull a corresponding code from a database or array
It needs to store that code in a dynamic variable and send a http request back out which includes that variable
It needs to do this sequntially
I’m assuming I should could use PHP for this

It needs to save each http post/get data and the corresponding id that was pulled into a datbase
It needs to check the http post/get data to see if a specific variable within that has been received before
If this has, it needs to send out a different message

Any thoughts or assistance would be great

What language to use
What database to use

What backup plans I could be into place

This application needs to run for 7hr event, which could hit the application with a lot of requests, so it needs to robust
It needs to be as fast as possible as well !