无论我们做什么系统,95%的系统都离不开注册,登录;
而游戏更加关键,频繁登录,并发登录,导量登录;如果登录承载不起来,那么游戏做的再好,都是徒然,进不去啊;
序言登录所需要的承载,包含程序和数据存储瓶颈,统一都可以看成io瓶颈;
我的登录服务器,操作只是做登录注册和返回服务器列表功能(只要其他负载均衡不讲解,软负载,硬负载);
登录服务器,分不同渠道登录验证,本地渠道验证,如果登录账户不存在,直接注册账户,然后返回token码;
其他服务器只认token登录需求;减少其他服务器的数据库验证,网络传输验证,io等开销;
我的登录服务器设计只接受 http 登录请求;
http不是通过web发出的;只是一个http监听协议而已;
本文,测试结果,
本机测试服务器标准是 I7 8C + 16G,Windows 10,
创建账号消耗4毫秒左右;理论上登录和创建账号是一致结果;
缓存登录,由于减少了数据库检束;
消耗基本是1毫秒左右;
也就说说
登、注的qps= 5000 =1000 / 4 * 20;
缓存登录 qps= 20000 = 1000 / 1 * 20;
--5000 注册,5000 登录,2万缓存登录 qps
数据库设计userinfo类
1 package net.sz.test; java.io.Serializable; 4 import javax.persistence.Column; 5 import javax.persistence.Id; 6 import javax.persistence.Table; * 用户信息表 10 * 11 * <br> 12 * author 失足程序员<br> <br> 14 * mail 492794628@qq.com<br> 15 * phone 13882122019<br> @Table(name = "UserInfo") UserInfo implements Serializable { serialVersionUID = -8907709646630947645L; 21 @Id id; String userName; String userNameLowerCase; @Column(nullable = false) 29 private String userPwd; @Column(nullable = false) 32 private String userPhone; @Column(nullable = false) 35 private String userMail; @Column(nullable = false) createTime; @Column(nullable = false) lastLoginTime; @Column(nullable = false) Status; String token; tokenTime; loginPlayerServerId; lastUplogintime; UserInfo() { 55 } getId() { 58 return id; 59 } setId(long id) { 62 this.id = id; 63 } String getUserName() { 66 return userName; 67 } setUserName(String userName) { 70 this.userName = userName; 71 } String getUserNameLowerCase() { 74 return userNameLowerCase; 75 } setUserNameLowerCase(String userNameLowerCase) { 78 this.userNameLowerCase = userNameLowerCase; 79 } String getUserPwd() { 82 return userPwd; 83 } setUserPwd(String userPwd) { 86 this.userPwd = userPwd; 87 } String getUserPhone() { 90 return userPhone; 91 } setUserPhone(String userPhone) { 94 this.userPhone = userPhone; 95 } String getUserMail() { 98 return userMail; 99 } setUserMail(String userMail) { 102 this.userMail = userMail; 103 } getCreateTime() { 106 return createTime; 107 } setCreateTime(long createTime) { 110 this.createTime = createTime; 111 } getLastLoginTime() { 114 return lastLoginTime; 115 } setLastLoginTime(long lastLoginTime) { 118 this.lastLoginTime = lastLoginTime; 119 } getStatus() { 122 return Status; 123 } setStatus(int Status) { 126 this.Status = Status; 127 } String getToken() { 130 return token; 131 } setToken(String token) { 134 this.token = token; 135 } getLastUplogintime() { 138 return lastUplogintime; 139 } setLastUplogintime(long lastUplogintime) { 142 this.lastUplogintime = lastUplogintime; 143 } getTokenTime() { 146 return tokenTime; 147 } setTokenTime(long tokenTime) { 150 this.tokenTime = tokenTime; 151 } getLoginPlayerServerId() { 154 return loginPlayerServerId; 155 } setLoginPlayerServerId(int loginPlayerServerId) { 158 this.loginPlayerServerId = loginPlayerServerId; 159 } 160 161 @Override 162 public String toString() { 163 return "UserInfo{" + "id=" + id + ", userName=" + userName + ", userNameLowerCase=" + userNameLowerCase + ", userPwd=" + userPwd + ", userPhone=" + userPhone + ", userMail=" + userMail + ", createTime=" + createTime + ", lastLoginTime=" + lastLoginTime + ", Status=" + Status + ", token=" + token + ", tokenTime=" + tokenTime + ", loginPlayerServerId=" + loginPlayerServerId + ", lastUplogintime=" + lastUplogintime + '}'; 164 } 165 166 }
View Code
用来记录账户数据的;
登录功能划分设计渠道登录脚本接口设计