移动应用安全代码验证

I am planning to design an application that will offer an alternative security process that users can optionally add to their accounts.

My idea so far is to get the phone number of the mobile the user has downloaded the app for, then link the website account with the phone number, only one account per unique phone number.

Obviously, to improve the security the code will be randomly generated every 30 seconds. Therefore if the user wanted to login, the website -or- app would need the security code from the mobile the account is linked to.

One thing that I am stuck on is how I would make the app and website talk to each other and keep each constantly updated so the app would have a new security code for every user registered every 30 seconds (as long as they have the option enabled).

The security code would be stored in the database, (let's say we have at least a few thousand users with the option enabled) the amount of updates to the database would surely overload the server?

How would I go about doing this, and optimising the 'algorithm' for the server handle it.

Also, would a more 'powerful' database server, such as MariaDB be better in this instance than say, MySQLi, SQLite, etc.

Regards

This can be achieved with Two-Factor Authentication. Two-factor authentication adds a second level of authentication to an account log-in. When you have to enter only your username and one password, that's considered a single-factor authentication. In two factor authentication let us to add a unique code supplied from your phone or an external app while loggedin for another step of authenticaton.

With Two-Factor authentication, you can generate random number that will be changed every 30 seconds, That could be used when user logged.

You can implement two factor authentication by your own or you can use from existing one like GoogleAuthenticator for php. With Google Authenticator, it allows to create a secret key with that secret we can build qr-code. Once the qr-code has been read from Google Authenticator app, it will be generated on every 60 seconds.