In DSC S2, in the late 2250s, we get a reference to some 7,000 ships in active Starfleet service. How many of those would have a Captain as a CO? No telling. But in TOS S1, Kirk is doing a job "one in a million" could do. That's a few thousand humans, give or take, and a few million UFP folks overall if the DSC and later DS9 references to wars affecting "trillions" are to be considered.
Probably at least tens of thousands of people at Captain rank, then. And a Starfleet that is big enough to do what it is seen doing - which does
not entail, say,
1) winning wars against Klingons who can cloak
2) responding to colonial distress calls in time
3) finding out what happened to fellow starships in less than six months
4) stopping random riffraff from operating within UFP borders, or penetrating said, the heavily fortified RNZ nothwithstanding in the latter sense
So we can't really go by any "Starfleet ought to be this big" metric, but have to rely on what we actually
hear about the size. Which includes the 7,000-ship remark from DSC, the reference to a dozen Fleets of at least half a thousand ships apiece in DS9, and the ability to kick up ten thousand relief ships for PIC. Little is known about the non-starship aspects of the organization: starbase numbers go up to the 700s (TNG) or 200s (TOS), say, but we know there are gaps in the scheme, and we know starbase size varies rather extremely.
Then there's the Academy. As far as we know, there still is only the one. But as far as we know, it's the size of the city of San Francisco, and yearly attendance is in the millions...
Timo Saloniemi