C-End Service Storage Architecture

        What's C-End Service? C meas Consumer, so it's used to provide services for Consumer, such as buyers, in which there are many important issues , such as efficiency, reliablity and so on. The article refers to how to get a more efficiency C-End Service through the storage architecture. For C-End, all services latency in a request shouldn't be more than 500ms, otherwise it'll produce very bad customer experience and the user wouldn't like to use it any more. In order to get an efficient service, the most important solution is to improve the storage architecture. In general, the following three level storage architecture, which are local cache, remote cache and  persistent DB, such as mysql,  will be used in C-End Service.

        Because local cache uses the memory of the service host and it has the size limit, it's better to store the hotspot data, which will expire after some time,  then it can avoid using too much memory and negatively impacting service performance. For remote cache,  such as redis, which has its own memory and has a cluster to manage it, the full data could be stored, then it can get better performance for the service.

        Although remote cache can also do data persistence, it would slow down the service performance and these persistent data has no business value here except data reliablity, in other words, the data could only be used by C-end services and won't be accessed by some services with low real-time requests, such as offline services, because it's too expensive for there serivices.

        Persistent DB is used to store full data and all data will be persisted into hard disk to avoid data loss. Although its performance is much lower than remote cache, its access cost is also much lower, so it's suitable for a small number of penetrating cache requests and non-real-time offline requests.

        Now, Local cache contains two kinds of products, which are Guava and Caffeine. They are all K/V structures  and based on ConcurrentHashmap principle.  Their difference are shown in the tabel below.

GuavaCaffeine
LockSegment Reentrantlocksynchronized+CAS
Eviction StrategySyncAsync
Default Eviction AlgorithmS-LRUW-TinyLFU
Data StructureHashMapHashMap
Cumulative Statisticyesyes
spring default cachespring4 and earlier spring5
Automic LoadYY

           For remote Cache, there are two products, such as Redis and Tair, They are all K/V data structure, but they have some difference, Redis has four modes, such as  Single, Master-slave, Sentinel and Cluster. Tair supports several storage engine, for example, mde, rdb and so on, whichi is used for different use case. The following table are their difference.

Redis clusterTair
Write latency1-2ms5~8ms(write through),1ms(write back)
Read latency1-2ms1ms(memory), 5-8ms( disk)
Throughput per host5W8W-10W(key+value=1k)
V sizeno more than 1G(Preferably no mroe than 1M )no more than 256M
V data structureString/Hash/List/Set/ZSet
Cluster hosts size1000+no limit
CAPAPCP or AP
Languagejava、rubyphp,restful,java,c/c++
Automic ExpirationYesYes
ExtensionManualAutomic
ReliabilityPer user demandsStory
Business IsolationNoPer Group or name in a Group

        For persistent DB, there are Mysql, DDB, whose data is stored on Disk to avoid data loss. Although there are other persistent DB, such as ES, HBase and so on, we focus on data storage in C End, so only Mysql and DDB are more important for us and the followingt table are their difference, 

Mysql(InnoDB)DDB
Data StructureRelational DBK/V DB
TPS900 per second1000 per partition per second(WCU)
QPS3-4W per second 3000 per partition per second(RCU)
  • 14
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值