Git Product home page Git Product logo

keepstudyingahead / distributed-system-framework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lexingsen/distributed-system-framework

0.0 0.0 0.0 10.34 MB

这是一个基于Linux平台,C++编写的分布式系统。服务器端采用了线程池+Libevent的IO模型,并为其实现了简单的负载均衡。服务器端业务层使用了MVC的设计模式。数据存储方面对MySQL数据库C-API进行了C++的类封装。为了实现服务器集群的负载均衡,实现了以一致性hash为底层算法的负载均衡服务器,这可以作为一个单独的模块。

C++ 96.79% C 0.66% CMake 2.48% Shell 0.08%

distributed-system-framework's Introduction

分布式系统框架

一.项目简介

基于Linux平台C++编写的分布式系统框架,非常适合对Linux后端项目有需求的同学学习。

主要包含服务端,负载均衡服务器,客户端,信息采集器,数据库连接池等
涉及到的技术:

(1)Linux下socket编程, 封装TcpServer,TcpClient

(2)Libevent网络框架库的使用

(3)服务器端线程池模型的创建使用以及其负载均衡

(4)MySQL数据库C接口的C++类封装

(5)数据库连接池

(6)单例模式

(7)负载均衡算法之一致性hash算法

(8)CJson格式的消息封装

(9)MVC设计模式处理具体业务

(10)MD5算法

(11)cmake

三.项目依赖及编译

  • 三方库
    • libevent
    • mysql
    • json
    • openssl(md5算法)
  • 编译
    • 编译环境
      • g++ 7.5.0
      • cmake 3.10.2
      • os ubuntu 18.04
    • 编译
      source build.sh

三.部署

  • 1.安装好mysql数据库,配置好用户名和密码(name:root, password:111111)
  • 2.按照doc目录下的sql文件创建数据库和表
  • 3.首先启动负载均衡服务器
  • 4.启动多个服务器,主动连接负载均衡服务器,让其纳管
  • 5.客户端连接服务均衡服务器,让其分配一个合适的服务器ip+port,客户端收到ip+port后,主动去与服务器建连

四.项目工作流程

五.其他的想法

  • 负载均衡服务器与服务器之间的连接属于长连接,设置心跳包或keepalive保活机制
  • 增加redis缓存层

六.项目架构

七.QQ交流群

823170006

distributed-system-framework's People

Contributors

lexingsen avatar

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.