The spawner itself - and every position of live mobs within it (drop chute, kill chamber etc) must be less than 128 blocks from the player's afking position (and its spawn floors can't be closer than 24 blocks). All non-spawner spawning locations (unlit caves, unlit terrain etc) must be farther than 128 blocks from the player's afking position. The distances are counted as a sphere centered on the player's feet.
If you're building a farm where the player manually kills the mobs, that means preferably building it over ocean (no need for extra height, and all accidental falls while building it will be survivable) with the kill chamber above y=190 (remember, unlit water is spawnable for drowned!) and the spawning floor such that the mobs drop 24 blocks to the killing floor. If you're building a fully automatic farm, you can (and should) build it as low as possible above spawnable spaces (to improve the number of spawns) and keep the player's afking platform high up, at y=190 or so, slightly off to the side from the farm (no blocks above the farm itself). If you want to go full mega-industrial, create a perimeter - a hole down to bedrock, 128 blocks radius around the player's afking spot completely empty, and build the farm as low as possible. You'll probably need some mechanisms to move mobs where they can be automatically killed, e.g. using Nether portals to bring them to a kill chamber in the Nether.