SpringRaft:使用Spring MVC和Spring WebFlux的筏式共识算法实现

  • b0_862253
    了解作者
  • 70.6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 03:40
    上传日期
弹簧筏 SpringRaft是一个学位论文项目,包含在Servlet和Reactive堆栈中的Raft共识算法实现中。 此实现应该是模块化的,以便可以对其进行扩展,并且应该是通用的,以便可以在不同的用例中重用它们。 该项目的最终目的是在这种情况下比较两个堆栈。 回购结构 在Raft实现之前和之后构建的示例和测试位于test-examples/ 。
SpringRaft-main.zip
内容介绍
# Distributed Counter This example represents a counter implemented in both stacks, which can be incremented, decremented and accessed. This counter is an entity in the database, and to ensure no lost-updates occur, it is used Optimistic Locking. In case of rollback, the operation of increment/decrement is repeated, until a commit is reached. This is possible because both operations are commutative. When there are more than one server, one of them has to be the leader, so it can handles the client requests and broadcast them to the other servers. No protocol is assumed, no timeout is treated, no lost communication is retransmitted. It is just an example that explores important parts of the Raft algorithm (communication and persistence), and collects preliminary results to compare stacks. ## Deployment To deploy one server only, you just need to be in the root folder of one stack, then: * `mvn spring-boot:run` To deploy, for example, 3 servers, you need to run this commands in separate tabs: * `mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8001 --group.leader=true --group.members=8001,8002,8003"` * `mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8002 --group.members=8001,8002,8003"` * `mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8003 --group.members=8001,8002,8003"` In the end you'll have 3 servers (8001, 8002, 8003), where 8001 is the leader. ## Benchamark To run tests against the cluster of servers, it is used [wrk](https://github.com/wg/wrk) benchmark. If you are in the benchmark folder you can run, for example: * `wrk -c 64 -d 1m -t 64 -s CounterIncrementPost.lua http://localhost:8001/counter/increment` * `-c`: Number of concurrent clients making requests * `-t`: Number of threads that handle the existing clientes * `-d`: Benchmark runs for 1 minute * `-s`: Script that contains the POST to the API * `http://localhost:8001/counter/increment`: Route to the leader API
评论
    相关推荐
    • Spring MVC
      Spring MVC使用注解配置。。。。。。。。。。。。。。。。。。。。。
    • spring mvc
      本代码是spring mvc的一个小demo 只是完成mvc的一个实例。没有复杂的业务逻辑 本demo只是适合刚学习Spring mvc的同行
    • spring mvc
      spring mvc spring mvcspring mvc
    • Spring MVC
      一个简单的spring mvc登录案例,采用的是annotation方式。
    • spring mvc
      spring mvc 开发所需要的全部工具、jar包
    • spring mvc
      spring mvc spring 配置文件
    • Spring MVC
      一个spring mvc 小demo.
    • spring mvc
      spring mvc最小代码。spring mvc最小代码。spring mvc最小代码。spring mvc最小代码。
    • Spring MVC
      spring mvc开发所需要的所有jar包,以及基本的spring集合
    • spring mvc
      一个spring mvc 的小实例,较好的理解spring mvc.