Published
Edited
Jun 26, 2019
Insert cell
md`# Cost of LiveChat`
Insert cell
md`# 常量`
Insert cell
days = 30
Insert cell
person = 1000
Insert cell
hours = 12
Insert cell
sendMessage = 100
Insert cell
receiveMessage = 100
Insert cell
messageSize = 3 //3k
Insert cell
md`## API Gateway`
Insert cell
Insert cell
function messageCost(messageTotal) { return messageTotal/1000000 * 1.06 } // 前 10 亿: 1.26 超过 10 亿: 1.06 USD
Insert cell
function connectCost(connectTotal) { return connectTotal/1000000 * 0.315} // 0.315 USD
Insert cell
md` message cost:`
Insert cell
messageTotal = (sendMessage + receiveMessage) * 1000 * 30 // 100:条发送消息 500:条接受消息 1000:个人 30:天
Insert cell
messageCostPrice = messageCost(messageTotal) // USD
Insert cell
md`connection cost:`
Insert cell
connectTotal = person * hours * 60 * days // 1000:个人 12: 小时 60:分钟 30: 天
Insert cell
connectCostPrice = connectCost(connectTotal)
Insert cell
md`### total cost:`
Insert cell
TotalCostofAPIGateway = connectCostPrice + messageCostPrice // currently 1.9 USD
Insert cell
md`## AWS Lamda`
Insert cell
md`Cost functions:`
Insert cell
function functionCost(count) { return count/1000000 * 0.2 } // 100 万个请求 0.2 USD
Insert cell
md`Function count:`
Insert cell
FUNC_ONCONNECT_COUNT = person * days
Insert cell
FUNC_DISCONNECT_COUNT = person * days
Insert cell
FUNC_ONMESSAGE_COUNT = person * receiveMessage * days //接收 100 条
Insert cell
FUNC_SENDMESSAGE_COUNT = person * sendMessage * days //接收 100 条
Insert cell
FUNC_PING_COUNT = hours * 60 * 60 / 15 * person * days
Insert cell
FUNC_GET_OWNER_STATUS_COUNT = person * days
Insert cell
FUNC_GET_CONTACT_STATUS_COUNT = person * days
Insert cell
md`total function cost:`
Insert cell
functionCostPrice = functionCost(FUNC_ONCONNECT_COUNT + FUNC_DISCONNECT_COUNT + FUNC_ONMESSAGE_COUNT + FUNC_SENDMESSAGE_COUNT + FUNC_PING_COUNT +FUNC_GET_OWNER_STATUS_COUNT + FUNC_GET_CONTACT_STATUS_COUNT)
Insert cell
md`# DynamoDB Cost`
Insert cell
md`Cost functions:`
Insert cell
function readWriteCost(writeCount, readCount) {return writeCount/1000000 * 1.4269 + readCount/1000000 * 0.285 } //每百万写入请求单位 1.4269 USD ; 每百万读取请求单位 0.285 USD
Insert cell
function storageCost(storage) {return storage * 0.285 } //每月存储的前 25 GB 免费 ,之后的部分为每月每 GB 0.285 USD
Insert cell
md`readWrite cost:`
Insert cell
readWriteCostPrice = readWriteCost(sendMessage * person * days, person * days)
Insert cell
md`storage cost:`
Insert cell
storageCostPrice = storageCost(sendMessage * person * days * messageSize/(1024 * 1024)) //
Insert cell
md`# Total Cost`
Insert cell
totalPrice = functionCostPrice + TotalCostofAPIGateway + readWriteCostPrice + storageCostPrice
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more