My webservices are as structured as follows:
- Receive request
- Parse and validate input
- Do actual webservice
- Validate output
I am primarily using logging for debugging purposes, if something went wrong I want to know what the request was so I can hope to reproduce it (ie. send the exact same request).
Currently I’m logging to a MySQL database table. After 1. a record is created, which is updated with more info after 2. and 3. and cleaned up after 4. (Logs of successful requests are pruned).
I want the logging to be as quick and painless as possible. Any speed up here will considerably improve overall performance (round trip of each request).
I was thinking of using INSERT DELAYED but I can’t do that because I need the LAST_INSERT_ID to update and later delete the log record, or at least record the status of the request (ie. success or error) so I know when to prune.
I could generated a unique id myself (or at least an id that is ‘unique enough’) but even then I wont know the order of the DELAYED statements and I might end up trying to update or delete a record that doesn’t exist yet. And since DELAYED also removes the ability to use NUM_AFFECTED_ROWS I can’t check if the queries are effected.
Any suggestions?
I figured I can probably just do a
REPLACE DELAYEDand do the pruning some other time. (with aDELETE DELAYED).