You can allow a certain app to run in the background by going to Settings > Apps & notifications > Advanced > Special app access > Battery optimization . This will initially show you the apps which are Not Optimized – that is, the ones that can run in the background even while the phone is sleeping.
Read moreShould I limit background processes android?
By limiting the background process, users tell the operating system not to run in the background and keeps on eating unnecessary resources . Notably, limiting background process simply puts all the background process to sleep but that does not mean notification from email, WhatsApp, etc won’t be delivered.
Read more