16

Let's say I want to have a server with as many user accounts as possible. How many is the max?

I want millions of user accounts. Is that crazy? I'd host dozens of load-balance mirrors of the box, and user data would be stored on a highly available storage share, while all other data is assumed to be volatile.

2
  • "I want millions of user accounts. Is that crazy?" - Yes. Use a directory for this many users, not dozens of mirrors for that many users.
    – MDMarra
    Jan 9, 2012 at 19:49
  • Does this answer your question? Maximum number of users on Linux
    – malat
    Jan 28, 2020 at 10:55

4 Answers 4

23

Theoretically you can have as many users as the user ID space supports. To determine this on a particular system check out the definition of the uid_t type. It is usually defined as unsigned int or int meaning that on 32-bit platforms you can create up to almost 4.3 billion users. On 64-bit platforms you can have more than 16e18 different user IDs.

However, other resources may become exhausted before you reach this limit, e.g. disk space. If you create a home directory for each user then even with just 1MB of space for each user you need over 4PBs of storage. Also, large number of users leaving processes running in the background, scheduling cron jobs, opening ftp and/or ssh sessions can create a severe burden on the system.

2
  • 1
    +1 for mentioning resources... Then again, unix-like systems allow for insane hardware configurations.
    – HTDutchy
    Jan 3, 2012 at 2:12
  • Are you sure about the 32-bit vs 64-bit difference ? Can you add a reference ? Here is what I find 1 and 2
    – malat
    Jan 28, 2020 at 10:52
8

Up until the UID space is exhausted. Contemporary systems use 32-bit unsigned integers, with 65535 and 4294967295 being magic values for "any"/"unknown"/etc., so there is room for 4294967294 concurrent distinct users. Older systems may still show 16-bit unsigned integers.

1

Other answers have responded literally to OP's question regarding specific limits. Given the nature of SF as a long-term reference too, I think it's important to point out a very important caveat on the approach you're contemplating.

You want to be using a directory service to manage user accounts on this scale. It's exactly the problem that directory services [e.g. OpenLDAP, Active Directory, et al.] were designed for.

Using "standard"[1] Unix user tools to manage more than a handful of local user accounts is a well-worn pathway fraught with pain, will not scale very easily and - given your problem description - will in all likelihood lead to a significant re-architecting of your chosen solution when it does not in fact scale horizontally with multiple servers.

[1] They generally work very similarly, but the exact incantations vary from platform to platform, are different sometimes even in similar heritage Linux distros and of course are regularly changed with OS release versions. Caveat emptor.

0

As above you are limited by the UID unsigned int size theoretically but will most likely be restricted by resources at present before reaching said limit.