Develop Where You Deploy
So I once spent a whole day figuring out why a Python script wasn’t running in prod. It worked perfectly on my Ubuntu machine but would always crash when running on Alpine based docker images.
The culprit was libc. I was developing on a machine that uses glibc and running my applications using musl based docker images. When you pip install something on Ubuntu, you’re given wheels built for glibc which won’t run on musl based systems.
There are other things that can differ between musl and glibc as well like name resolution. You may find that your application can resolve names on your dev machine but in prod it’ll timeout. This is due to musl resolving names slightly different than glibc.
Also memory and thread handling can vary (among other things that I’m sure I’m missing). These are just some of the many differences that can make you lose a few hairs.
My solution is to use the same runtimes in development as you have in prod. If you are using musl try and develop on it (or at least test on it). If your prod server is using python 3.9.2 don’t develop on 3.9.7 just because it’s a little newer.
I know most people won’t want to give up their Mac to develop on. But you can easily use docker to test your applications against your prod image. Run it once before you push and it may save you time debugging in prod.