Giter Site home page Giter Site logo

policycontroller's Introduction

Flash Sale System Demo

Flash sale becomes more and more popular among the ecommerce platforms. but there are few articles/blogs addressed the system in detailed level. And hardly find the code samples. Here we are. This system contains 5 separated micro service: GateKeeper, SafeProtector, PolicyController, InventoryManager and Shopping Cart. 闪购在电商中已经越来越流行。现在很少有资料详细的介绍闪购平台的架构,也很少有源码参考。我这个闪购平台的系统包含了5个微服务:: GateKeeper, SafeProtector, PolicyController, InventoryManager and Shopping Cart. The objective of the flash sales system is to handle the massive customer requests, filter the traffic based on the business logic ,and protect the back end system. In order to get more scalability , all this micro service can deployed on Docker. 闪购平台的目标在于能够处理前端大量的请求,按照业务要求请这些请求逐级过滤,并能够很好的保护后端的系统,避免后端系统被巨量的请求压垮。

感谢马利超同学的分享,这个DEMO的许多想法源于此。

Micro Service

#####GateKeeper Service this micro service will sit front of the whole system, it will handle the massive client requests and keep the connection with those clients, and will be re-distribute the request to others micro service.

#####GSafeProtector Service this micro service will filter the request by IP and Account ID. Once the request matches the blacklisted IP and Account ID, this request will be reject. And we will analytics the traffic in near real-time period , and will update the backlist dynamically.

#####PlicyController Service this micro service will process the business logic. Currently can set the limitation of purchase unit according to the user level.

#####InventoryManager Service this micro service will manage the goods inventory. We will check the inventory information when user adding goods to the shopping cart.

#####ShoppingCart Service this micro service will manage the shopping cart of the customer, and will freeze the quantity of the specified goods when it was added to shopping cart successfully. And will release the goods based on some time periods.

#####EurekaServer Service this micro service will manage the service discovery and health mornitoring.

System Architecture

architecture

Service API

Name Path Method Request Body Response Body
doPolicyValidation /validate/sid/{sid}}/userid/{userid}}/userlv/{userlv}}/sku/{sku}/quantity/{qty} GET None {"sessionID":"sid00001","userID":"FS000001","goodsSKU":"QT3456","userLevel":5,"orderQuantity":1,"isAllowed":true,"isThrottled":false,"version":"1.0"}
addPolicy /policy/add POST {"goodsSKU":"SKU0001","userLevel":5,"quantityLimit":1} {"goodsSKU":"SKU0001","userLevel":5,"quantityLimit":1}
addUserOrders /user/add POST {"userID":"UID0000000001","goodsSKU":"SKU0001","userLevel":5,"orderQuantity":1,"isAllowed":false} {"userID":"UID0000000002","goodsSKU":"SKU0007","userLevel":5,"orderQuantity":1}
findAllItems-Policies /policy/all GET None [{"goodsSKU":"SKU0001","userLevel":3,"quantityLimit"}]
findAllItems-UserOrders /user/all GET None [{"userID":"FS00000001","goodsSKU":"QT3456","user}]
getPolicy /policy/sku/{sku} GET None {"goodsSKU":"SKU0001","userLevel":5,"quantityLimit":2}
getUserOrders /user/userid/{uid}/sku/{sku} GET None {"userID":"UID0000000001","goodsSKU":"SKU0001","userLevel":5,"orderQuantity":1}
removePolicy /policy/delete/sku/{sku} DELETE None {"goodsSKU":null,"userLevel":0,"quantityLimit":0}
removeUserOrders /user/delete/userid/{uid}/sku/{sku}} DELETE None {"goodsSKU":null,"userLevel":0,"quantityLimit":0}
updatePolicy /policy/update PUT {"goodsSKU":"SKU0001","userLevel":5,"quantityLimit":2} {"goodsSKU":"SKU0001","userLevel":5,"quantityLimit":2}
updateUserOrders /user/update PUT {"userID":"UID0000000001","goodsSKU":"SKU0001","userLevel":5,"orderQuantity":2} {"userID":"UID0000000001","goodsSKU":"SKU0001","userLevel":5,"orderQuantity":2}

Performance

To-do

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.