RequestLogsFeature pegging the db cpu - why is there a write then read?

We have the RequestLogsFeature enabled and have noticed that it can and will bring our db to it’s knees. (postgresql xlarge on amazon) with 100% CPU usage.

One thing I notice that I can’t figure out is there is an insert followed by a full select of that record. This takes on average 1-2 seconds. I understand the insert but not the select.

What’s the reason for the select?

We’ve temporarily had to disable all indices and likely logging all together.

I don’t know what you’re referring to either, do you have exact logs of what you’re referring to?

So when looking at postgres logs for the requestlog db we see the following…

You can see there are just as many selects as there are inserts. Now, they are a small fraction of what the inserts are. This snippet is more recent where avg times have decreased due to lower site usage for time of day, but at peek we are getting 1-2 seconds.

Are you using your own DB MemoryLogger? ServiceStack comes with 3 Request Loggers:

  • CsvRequestLogger
  • RedisRequestLogger
  • InMemoryRollingRequestLogger

None of which logs to a database, so I’m assuming you’re using your own custom IRequestLogger? The Select is likely a result of you using Save() which checks to DB to see if it already exists, instead of Insert() which inserts without checking.

Well, total oversite on my part. We are using a custom db logger which does use a save rather than insert. Thanks!