[System Design] Database system-------Account system Q1_design User system

Source: Internet
Author: User

Q1,design an account System

<1> first look at the scene scenario:

The simplest is to find an example, such as the user system of Twitter.

Consider what needs to be: 1,register/updata/remove.2,login/logout.3, balance/menbership.

Consider what is most important in the requirements, what is most frequent: login/logout most frequent, but login than the Logout frequency should be much larger, so consider login to be able, in addition register is also very important, also need to design first alone.

<2> Estimating and calculating necessary (QPS):

1.Register:

ASK:

Total users:1,000,000,000 (then egg)

Daily Active users:1,000,000 (important)

Predict:

Register percentage:1% ~ 10% can, generally look at the flow, the new system is probably 20-30%, the old system 3-5% is also reasonable, here with 1%.

Daily active users in three months:1,000,000 * 2 = 2,000,000 (estimation) factor can be 1.5/2/3 is reasonable

Because we do a system all for three months, all the design standards are three months later.

Daily Register users:2,000,000 * 1% = 20,000;

Register QPS = 20,000/86400s < 1QPS ==> stand-alone handling no problem at all

2. Login:

Predict:

Login percentage:15%

Average Login times:1.2 (because not everyone login can enter the password, the total error when)

Daily Login time = 2,000,000 * 15% * 1.2 = 360,000

Login frequency = 360,000/86400 S = 4.2/s

Normal Login Frequency = 4.2 * 2 = 8.4/s

Peak Login Frequency = 4.2 * = 42/s

<3> Application:

<----> Receptionist (Task Dispatcher) <----> account Service {register/updata/remove, login/logout, balance/ Membership}

<4> Data:user (V1)

Class User {

Private

int userId; Primary key ==> save space, select quickly

String name;

String password;

}

Usertable:

Class usertable{

Private

vector<user> table;

Public

... insert (...);

.... Delete (...);

... update (...);

.... Select (...);

}

___________________________

|  UserID |  name | password |

--------------------------------------

|            |                 | |

|            |                 | |

--------------------------------------

    

[System Design] Database system-------Account system Q1_design User system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.