最近在写一个distributed cache,把设计思想分享一下
来源:互联网 发布:json数组添加对象 编辑:程序博客网 时间:2024/06/06 00:33
Source code: https://github.com/gilbertwang1981/cache.git
Dependency: https://github.com/gilbertwang1981/commonlib4c.git
Language: C++/JAVA
Cache manager is under development.
Architecture Overview
1. Application could access the cache service through load balance based on the fourth layer of ISO-OSI 7-layer protocol such as LVS etc.
2. The Cache service provides the API for the application to access to the cached data.
3. The cached data could be replicated among cache instances.
4. The cache manager could configure the instance of the cache, collect the information from the cache instance such as CPU, Memory and statistic data etc. and monitor the cache instance.
5. The cache instance will be run as a process which could be deployed on the same machine.
6. The cache instance will provide two types of the data storage. The one is that the cached data will be stored on the disk in form of the fastdb data file. The other is that the cached data will be stored in the memory.
Main Protocol
1. The communication protocol based on the TCP long or short connection is binary.
2. The format of the protocol includes the header and body. The length of the header is 12 bytes. The length of the body is variable. The format of the protocol header is as follows.
Field
Size (byte)
Description
length
4
The total length of the pack
command
4
Command such as
get, set, del and
replication etc.
version
4
Protocol version
3. The format of the body request is as follows.
Field
Size (byte)
Description
Key length
4
The length of the key
Key
Key length
The key
value length
4
The length of the
value(just for set
command)
value
value length
The length of the
value(just for set
command)
timeout
4
The timeout of the
Key (just for set
command)
4. The format of the body response is as follows.
Field
Size (byte)
Description
Result code
4
Result code
description
64
The description for
the cache server
value length
4
The length of the
value(just for set
command)
value
value length
The length of the
value(just for set
command)
5. The format of the replicated message is as follows.
Field
Size (byte)
Description
The length of the
cluster IP address
4
The length
The cluster IP
The length of the
cluster IP address
The cluster of the IP
……
……
……
The body of the
command
variable
get/set/del command
- Detail
1. How was the data expired?
The lazy expiration was applied on the cache. When the application gets the data from the cache, the cache will decide whether the data will be expired.
2. How the replication will be run?
The command will be forwarded one cache instance for another via a router table in the message. The consistence of the copies will be verified by the cache manager in the cluster.
3. What is the main data structure of the cache in-memory mode?
M-Tree,the key will be stored on the non-leaf node. The data will be stored on the leaf node.For example, the key is “abc”, the value is “hello world”and the key is “ab”, the value is “hello world”. The memory layout for this KV pair is as follows.
4. What is the cache manager?
The cache manager is responsible for:
a) Managing the cache instances for the cluster.
b) Monitoring the cache instances for the cluster.
c) Configuring the cache instance into the cluster.
d) Removing/Adding the cache instance out of/in service dynamically.
e) Providing the CLI (Telnet)interface for the remote operator.
f) Ensuring the data consistence for the cache cluster by the global bitmap.
5. How the disk-mode implements?
Use fastdb.
- 最近在写一个distributed cache,把设计思想分享一下
- 最近在看反射,觉得写的还不错,分享一下
- 蛙蛙推荐:最近开发一个小型的OA,把常用代码和大家分享一下先
- 最近找到一个很好的 API CODE 网站,分享一下
- 最近在写一个黄页收集程序
- 分享一个最近写的Scenekit 的 demo
- 分享自己最近在写的电商平台
- 前两天写的一个菜单和大家分享一下
- 好久没写BLOG了,把最近读的几本书贴一下
- 最近在学Java,想想后面会遇到很多问题,写个博客分享一下
- 分享一下最近写的仿支付宝支付键盘密码输入框demo
- 最近开发写了两个简单的进度条控件,分享一下
- 【设计分享】一个面向对象思想的perl编程实例
- 最近发现一个很好的G站,99wg站,和大家分享一下的了
- 分享一下最近做的一个项目,呵呵,感觉挺难的样子
- 最近用Timer踩了一个坑,分享一下避免别人继续踩
- 最近遇到了一个用placement new动态创建二维数组的问题,分享一下
- 最近实现的一个分离文章内容功能,挺有意思,分享一下
- Spring与Velocity
- Spring整合JMS(一)——基于ActiveMQ实现
- mysql 错误解决方案-积累
- PHP防盗链文件下载的基本思想
- jdk7/8 TOMCAT7
- 最近在写一个distributed cache,把设计思想分享一下
- Spring整合JMS(二)——三种消息监听器
- linux mysql 操作命令
- extjs5搭建管理系统-环境搭建
- weblogic--配置文件路径错误--空指针异常--classes目录下为空
- spring事务一
- POJ3714(分治)
- 设计模式 -- 工厂模式(Factory)
- 如何做到比产品经理更懂产品