3 ms·
Build everything to be as easy as possible to debug, because everything else you can do at work after a nice cup of coffee, debugging is the only thing you migh
by ltbarcly3 8y ago
Build everything to be as easy as possible to debug, because everything else you can do at work after a nice cup of coffee, debugging is the only thing you might have to do at 3AM while drunk.
So:
- Set up some kind of logging, by default use rsyslog and set it up so your logs are available somewhere other than the machine where something is running. You will be surprised how often something breaks and takes the server down with it so you can't log in.
- Later on, when you have to debug stuff, READ THE LOGS. I can't explain it, but after years of working on production systems I have noticed that almost nobody actually goes back and just reads the logs when things go wrong. You will find the problem spelled out in the logs 99% of the time. YOU CAN'T JUST GUESS WHAT WENT WRONG.
- Use transactions properly.
- If you use an ORM, do whatever you need to do to keep track of how many actual queries are done. You are going to find that you do some order of magnitude more queries than you thought. Learn how to give the ORM hints to avoid this.
- abraae 8y agoGood stuff! Especially the ORM. And work on your logs. Tweak the info/error/debug levels so that the log files read nice. Too often we find that a common error/exception will spew hundreds of lines of shite into the log files over and over again, obfuscating the real information. Take pride in having meaningful, concise but informative log files.
- ltbarcly3 8y ago> log files read nice YES! At one company I was at their web service framework would log thousands of lines of nonsense for every request, most of it errors about not being able to connect to services that no longer existed or thousands of lines of debugging that were never relevant to anything. Make sure you are only logging sensible things (usually this means when you see something being logged for no reason or which is no longer relevant, fix things), and if you want to log a ton of garbage, set things up so you can tell the difference and throw out the junk.
- creatornator 8y agoYeah blindly using ORM query builders can result in a bunch of N+1 query issues, and retrieving unnecessary data, which can impact the database load. Good advice