Basic Authentication using DBM based storage

Here Apache HTTP Server makes use of Basic Authentication using DBM storage for authentication database. Make sure to read Setting up Authentication and Authorization before proceeding.

Flatfile based storage stores usernames and passwords in plaintext. Everytime a user is verified, a request is made to the server. So, as the number of user entries increase, the process slows down in proportional to the size of the password file. This is because the server has to open up the password file, and go down the list of users until it gets to the required one. And this has to be done every time a request is made. So there is a practical limit to how many users can be put in a password file. This limit will vary depending on the performance of a particular server, but slowdowns are expected once we get above a few hundred entries.

A solution to this is to store usernames and passwords in a database. Apache HTTP Server currently supports the DBM databases Berkeley DB 2, NDBM, GDBM and SDBM.
Apache HTTP Server provides the utilities dbmmanage and htdbm for creating and managing DBM authentication databases that use Basic HTTP authentication.
There are a number of different DBM file formats in existence. All these libraries use different file formats. dbmmanage/htdbm currently has no way of determining what type of DBM file it is looking at. If used against the wrong format, dbmmanage/htdbm may simply return nothing, or may create a different DBM file with a different name, or at worst, it may corrupt the DBM file if we were attempting to write into it.
We can use the file utility supplied with most Linux/Unix systems to see what format a DBM file is in.
EXAMPLE: # file testfile.dbm

dbmmanage/htdbm prefers the Berkeley DB 2 file format. This is because the order in which dbmmanage/htdbm will look for system libraries is Berkeley DB 2, NDBM, GDBM and SDBM. The first library found will be the library dbmmanage/htdbm will attempt to use for all DBM file transactions.
This format preference is made possible by @AnyDBM::ISA