基于微服务架构的商对客模式电商网站的设计与实现
2021-09-13张林
张林



摘 要:基于微服务框架搭建的“商对客”商业模式(B2C商业模式)的商城平台,对商城平台前后端进行分离,前端使用vue.js(视图层开发框架)进行页面渲染,后端采用微服务框架SpringCloud;每个微服务单体模块使用SpringBoot框架进行开发,微服务单体模块之间使用消息队列RabbitMq进行通信,使用Redis技术进行缓存。该设计实现了高可用、高并发和可扩展的全品类商对客模式电商网站,使客户与商家交易效率提高,给客户带来了良好的购物体验。
关键词:微服务架构;“商对客”商业模式;SpringCloud
中图分类号:TP311 文献标识码:A
文章编号:2096-1472(2021)-09-55-03
Abstract: This paper is based on a mall platform of the business-to-customer business model (B2C business model) built on the microservices framework, separating front and back ends of the mall platform. vue.js (view layer development framework) is used in the front end for page rendering, and SpringCloud, a microservice framework, is used in the back end. Each microservice monomer module is developed by using SpringBoot framework, the message queue RabbitMq is used for communication between the microservice monomer modules, and Redis technology is used for caching. The design achieves a high-availability, high-concurrency and extensible business-to-customer e-mall website of full-category goods, improving the efficiency of customer-business transactions and bringing customers a good shopping experience.
Keywords: microservice architecture; business-to-customer business model; SpringCloud
1 引言(Introduction)
隨着科学技术的日益进步,电子商务成为社会活动的重要部分,用户实现了在家一键下单,购买支付,一键退款,方便了人们的生活。以往的单体应用架构根本支撑不住如此强大的购物热潮,在客流量增大的情况下,服务器常常因为无法承受高并发量而造成宕机的问题,使用户体验感差。而后发展的分布式架构和SOA(粗粒度服务)架构扩展性差,耦合性高,也不满足此系统的需求。基于此,本文开发的系统商城平台采用微服务架构,按照业务被拆分为多个微服务,以松耦合的方式被独立部署[1],使用Spring(SpringCloud+SpringBoot)框架进行开发,Nginx(轻量级web服务器)作为反向代理,Redis(内存数据库)作为缓存,MySQL(关系型数据库)作为后台数据库;使用RabbitMq(消息队列)方式提高了全品类网站平台的响应速度,实现了商品显示、商品搜索、加入购物车、下单购买等功能。
2 技术方案(Technical solutions)
2.1 微服务架构
2.1.1 微服务
微服务是面向服务软件开发的最新发展趋势,其通常采用去中心化的服务管理方式[2]。……
