forked from aalansehaiyang/technology-talk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4b4db9
commit 35843e0
Showing
5 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
==== | ||
|
||
一、常用并发类 | ||
### 一、常用并发类 | ||
|
||
* Concurrent |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## dubbo相关 | ||
|
||
==== | ||
|
||
随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,亟需一个治理系统确保架构有条不紊的演进。 | ||
|
||
![image](../img/dubbo-1.jpg) | ||
|
||
|
||
* 单一应用架构 | ||
|
||
当网站流量很小时,只需一个应用,将所有功能都部署在一起,以减少部署节点和成本。 | ||
此时,用于简化增删改查工作量的 数据访问框架(ORM) 是关键。 | ||
|
||
* 垂直应用架构 | ||
当访问量逐渐增大,单一应用增加机器带来的加速度越来越小,将应用拆成互不相干的几个应用,以提升效率。 | ||
此时,用于加速前端页面开发的 Web框架(MVC) 是关键。 | ||
|
||
* 分布式服务架构 | ||
|
||
当垂直应用越来越多,应用之间交互不可避免,将核心业务抽取出来,作为独立的服务,逐渐形成稳定的服务中心,使前端应用能更快速的响应多变的市场需求。 | ||
此时,用于提高业务复用及整合的 分布式服务框架(RPC) 是关键。 | ||
* 流动计算架构 | ||
|
||
当服务越来越多,容量的评估,小服务资源的浪费等问题逐渐显现,此时需增加一个调度中心基于访问压力实时管理集群容量,提高集群利用率。 | ||
此时,用于提高机器利用率的 资源调度和治理中心(SOA) 是关键。 | ||
|
||
|
||
<br/> | ||
|
||
参考资料: | ||
|
||
[http://www.oschina.net/search?q=dubbo&scope=project&fromerr=OSwWxF3l](http://www.oschina.net/search?q=dubbo&scope=project&fromerr=OSwWxF3l) | ||
|
||
[https://github.com/alibaba/dubbo](https://github.com/alibaba/dubbo) | ||
|
||
[http://dubbo.io/User+Guide-zh.htm](http://dubbo.io/User+Guide-zh.htm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Goole Guava | ||
|
||
=== | ||
|
||
### 一、缓存相关 | ||
如果服务上要使用本地缓存,可以考虑使用guava框架。Guava Cache与ConcurrentMap很相似,但也不完全一样。最基本的区别是ConcurrentMap会一直保存所有添加的元素,直到显式地移除。相对地,Guava Cache为了限制内存占用,通常都设定为自动回收元素。在某些场景下,尽管LoadingCache 不回收元素,它也是很有用的,因为它会自动加载缓存。 | ||
|
||
#### Guava Cache适用于: | ||
|
||
* 你愿意消耗一些内存空间来提升速度。 | ||
* 你预料到某些键会被查询一次以上。 | ||
* 缓存中存放的数据总量不会超出内存容量。 | ||
|
||
``` | ||
private Cache<String, UserAuthTokenRecord> localCache = CacheBuilder.newBuilder().maximumSize(200000) | ||
.initialCapacity(100000).expireAfterWrite(30, TimeUnit.SECONDS).<String, UserAuthTokenRecord>build(); | ||
``` | ||
|
||
### 缓存回收 | ||
|
||
* ##### 基本容量的回收 | ||
|
||
1)设置了初始值和最大容量上限,如果逼近容量上限,就会触发回收机制。 | ||
|
||
* ##### 定时回收 | ||
|
||
1)expireAfterAccess(long, TimeUnit):缓存项在给定时间内没有被读/写访问,则回收。请注意这种缓存的回收顺序和基于大小回收一样。 | ||
|
||
2)expireAfterWrite(long, TimeUnit):缓存项在给定时间内没有被写访问(创建或覆盖),则回收。如果认为缓存数据总是在固定时候后变得陈旧不可用,这种回收方式是可取的。 | ||
|
||
* #####基于引用的回收 | ||
|
||
|
||
|
||
|
||
参考资料: | ||
|
||
|
||
[http://ifeve.com/google-guava-cachesexplained/](http://ifeve.com/google-guava-cachesexplained) | ||
|