分布式Session研究(一):Docker + spring boot +Nginx构建分布式应用

本文通过Docker部署两个Spring Boot应用和一个Nginx实现负载均衡,演示了分布式系统中Session管理的问题。作者详细介绍了如何构建Spring Boot服务,配置Nginx,以及通过集中式Session管理(如Spring Session + Redis)来解决Session不一致的问题。
摘要由CSDN通过智能技术生成

由于自己一直痴迷于大型分布式系统的设计原理与实践。奈何条件有限,毕竟还在读书,根本无法接触到真正的分布式,真正的大数据。便只能在自己电脑上通过docker这种虚拟化技术来自己搭建”分布式系统”来玩玩,体验一下分布式Session,分布式事物等等。

这篇文章将搭建出一个”分布式”系统,并先体验分布式系统中Session管理的问题,并通过集中Session管理方案解决

构建两个SpringBoot镜像,提供Session服务。

先使用SpringBoot搭建构建一个Restful 接口,并做一些很简单的Session操作。
Maven:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
        <relativePath></relativePath>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

然后写一个比较简单的Controller:

@SpringBootApplication
@RestController
public 
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值