As a feature on my website I have micro-posting with the ability for other users to reply with comments. When a user enters their account area they can view their posts and see comments too. I’m currently cleaning up after completion of this project and notice that when a user enters their account area my logs show the following: full log: here
I’m concerned about:
1) The part of logs where it shows a users photo being loaded several times. I’m guessing this is where the same user has left several comments on a few posts on another users or their own profile. It’s loading the same photo over and over again. Shouldn’t this just be done once then some how used again to load the photo each time it comes up again? or is it ok to have that same photo loaded again and again?
2) I noticed some places in the logs that show this:
CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = LIMIT 1
[9e77936f78cd46e332128ec31ccc5964] [127.0.0.1] CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = LIMIT 1
[9e77936f78cd46e332128ec31ccc5964] [127.0.0.1] CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = LIMIT 1
IT looks like it’s searching for nothing. Is this normal? If not then any idea why it could be happening? I would like to track down the issue and stop it. Other than this my site seems to be working flawlessly but I’m not sure if that’s the same story behind the scenes.
3) Is there anything in my logs that I should be looking out for? Any bad things to spot?
All advice appreciated
Kind regards
1) I’m thinking it’s OK to load the same photo more than once on a single page – the issue only comes up when a single user has posted multiple comments that load in a given area. If your pagination is 20 comments per page then it will always load 20 pictures if each post is by a different user; even in the most extreme case of 2 posters putting up 10 comments each, caching would only prevent 18 database queries – which I strongly doubt represents a noticeable performance improvement.
2) My guess is that there’s a query that’s looking for a user with the ID of
nil. To track that down, I’d narrow the misfiring query down to a specific method, then sprinkle in a fewputscommands around the queries to see what’s actually being looked up. Maybe even araise 'searching for nil id' unless idhere or there.3) If your app seems to be running OK, then there’s nothing specific in the logs to hunt for. Make sure you’ve got good unit test coverage and good feature test coverage (I like Cucumber for this kind of testing) and that should help ensure your app stability. The only time you should need to refer to your logs is if your tests are all passing but you still see something in the app behaving contrary to expectations – then you sift through the log to see if you can figure out why the app is misbehaving. Once you’ve got it, fix the bug and write a new test to make sure that you don’t accidentally regress the fix later.