Giter Site home page Giter Site logo

server-note's Introduction

计算机四大金刚

  1. 操作系统
  2. 计算机网络
  3. 算法
  4. 数据结构

服务经历过程

  1. 域名解析
  2. http请求
  3. 业务逻辑
  4. 数据库读取存储
  5. 响应数据

性能瓶颈

IO:磁盘IO、网络IO

磁盘IO:读写非内存型数据库(Mysql、MongoDB)

网络IO:第三方服务,包括http或者tcp

代码操作mysql也是通过网络传输的

优化具体实践

  1. 性能不够机器来凑

    系统设计无状态:不要将系统依赖于某个别服务器(如登录凭证不存在某个别台服务器)

    服务器前端的负载均衡:7层的Nginx负载均衡,4层Lvs负载均衡

    物理负载均衡:F5、A10

    DNS:运营商根据IP决定地理位置机房

  2. 移花接木

    冷数据、热数据分离:热数据放缓存(Redis)、冷数据落库

    秒杀:锁、串行无锁化

  3. 分身

    数据量大解决方案:分库分表分实例、数据库读写分离

常见术语

QPS(Query Per Second):每秒查询数,每秒系统能够处理的查询请求次数

mysql单机1000QPS、Redis单机10wQPS

TPS(Transactions Per Second):每秒事务数,每秒系统能够处理的事务次数

TPS是吞吐量,即处理的请求。一个TPS可能会查询多次,即执行多次QPS

一个接口性能最好保持在300ms内能够有响应

热数据缓存,冷数据落库

幂等性:就是用户对于同一操作发起的一次请求或者多次请求的结果是一致的,不会因为多次点击而产生了副作用

异步方案:1.使用while true一直循环去查(可以使用返回查询id的方式,后续通过queryid去循环匹配结果)2.使用mq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.