一个问题,博客需不需要 Redis?

2016-09-25 13:53:25 +08:00
 lufficc

前几天写的laravel-blog被老外看到了,然后问我了一个问题:

Why do we need Redis for a blog system? If this is truly a fast blog it should be fast just using a database, no?

我简单回单了一句,为了缓存,提高速度,结果他不依不饶:

Depends on the use case. What are we caching? Indexed queries in a relational database are usually very fast. Adding Redis makes for a more complex stack so it must be motivated. Are we not just talking about saving lower single-digit milliseconds here? And to do that we add a hard dependence on Redis, making hosting more complex, error-prone and expensive. I love Redis and use it when it's appropriate. I also love relational databases because they solve complex use cases in a performant way. I asked why it is motivated to add Redis for a blog engine, and I just get a hand-wavy "for caching" as an answer. What do we need to cache and why can't that problem be solved without the need for a Redis cache?

回答了一长串,具体看这里:here 截图:.

所以到底要不要缓存,我该怎么回答?强大的 V 友帮帮我

12048 次点击
所在节点    程序员
104 条回复
daya
2016-09-25 13:57:38 +08:00
自己的博客还不是想加啥就加啥,你就回答他: just for fun!
audestick
2016-09-25 14:01:20 +08:00
最好再搞个 cluster...
lichifeng
2016-09-25 14:03:16 +08:00
需要 自己的博客本来就是学习各种技术的试验田
反而一些生产环境才需要根据实际情况做决断
lufficc
2016-09-25 14:07:53 +08:00
@lichifeng 同意
abelyao
2016-09-25 14:08:22 +08:00
技术角度:就想楼上说的博客是试验田,可以尝试使用各种技术;
产品角度:网站该不该上缓存不是看访问量么?跟是不是博客没有一点关系;
lufficc
2016-09-25 14:09:02 +08:00
@daya 感觉老外真的好较真,还说加 redis 会对服务器带来一定影响,不过服务器多一个软件性能影响大不大?
hanai
2016-09-25 14:09:28 +08:00
玩的话需要,正常不需要。
添加个 redis 增加了复杂度。
audestick
2016-09-25 14:10:09 +08:00
@luffylcc 当然.因为是缓存,所以吃内存.典型的以空间换时间的关系.
lufficc
2016-09-25 14:11:26 +08:00
@audestick 你这么一回答,有点动摇了。。。。
qgy18
2016-09-25 14:11:56 +08:00
我的博客就用了很多完全没必要的技术,就是为了玩,自己开心就好。
https://imququ.com
maddot
2016-09-25 14:12:20 +08:00
it's just a toy project for practicing my skills
audestick
2016-09-25 14:13:31 +08:00
@luffylcc 放心上...我说了,最好搞一个集群,然后时不时来点压测,测试自己的网站的延迟和首屏渲染速度...反正都是练习和玩儿,just have fun
mokeyjay
2016-09-25 14:14:33 +08:00
一般都不需要啊,除非你博客访问量爆炸,或者数据库 io low 到爆炸。当然如果你只是为了锻炼自己那随便加, 1 楼+1
lufficc
2016-09-25 14:21:26 +08:00
@audestick 我慌了, v 友们真强大
lufficc
2016-09-25 14:21:55 +08:00
@mokeyjay 博客新建的,额,基本没啥访问量
bearqq
2016-09-25 14:22:49 +08:00
gae 增加 memcache 可以减少数据库查询次数, memcache 免费,数据库收费,或者说每日有限额。所以我写的博客是有 cache 的。

另一个本地小项目每次访问需要数据库大量搜索 like %xxx%,所以搜索结果加 cache 了。
lufficc
2016-09-25 14:24:25 +08:00
@qgy18 不错的博客,收藏,关注你 twitter 了,
lufficc
2016-09-25 14:30:16 +08:00
@abelyao 回复他了
benbenzhangqi
2016-09-25 14:30:29 +08:00
喜欢折腾就添加,不喜欢或者对速度没有要求的就算了
gouchaoer
2016-09-25 14:40:12 +08:00
他说的没错,你增加 redis 依赖很不好,而且 vps 开个 redis 很不稳定。。。你可以利用 apcu 来做 cache

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/308824

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX