Upgrading to MongoDB 4.0 involves several steps:
1. Upgrade config servers to replica sets following procedures for upgrading replica sets.
2. Upgrade shards by upgrading each replica set member individually.
3. Upgrade mongos processes one at a time by replacing binaries and restarting.
4. Set the featureCompatibilityVersion to enable backwards incompatible 4.0 features.
5. Consider application impacts such as upgrading drivers, frameworks, and inspecting code for removed/deprecated features.
6. Test upgrades in non-production environments before upgrading production systems.