No more than 2 years in a same company and always be interview ready. Keep regular contact with recruiters. There’s always a better opportunity.
This is exactly what my friend did. He earns double my salary even though I work in one of those big companies and do more than just development.
The smaller subs I regularly visit are back to normal.