This depends on many factors, including your position as a player and the type of terrain around you.
Mobs will despawn when they are out of a 128 block radius of the player.
This means that for the spawner to be active if the player is anywhere within 128 blocks at the spawner's level, it has to be at least 128 blocks above the ground. This works for pretty much any generic mob farm, and it works in a populated server. Having blocks in an area above level y128 can decrease efficiency of mob spawning, since it has to account for more chunks, though, so here are some other options:
If you want to make a less tall, but still efficient design you can locate the player above the farm so that the despawn radius includes the spawner but excludes the rest of the world. Note that this design is better suited for AFKing, since you will have to make many trips up and down for this to work. This can be used for witch farms, as well as hostile mob farms.
You can also "sanitize" a 128 radius area, by lighting up every cave and surface you can find. This is obviously quite tedious, but it can allow for a ground-level farm that is active no matter where the player is. This works for witch farms as well, and is probably your best efficiency if you are playing on a server.