一个问题,博客需不需要 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 友帮帮我

12529 次点击
所在节点    程序员
104 条回复
BreakingBad
2016-09-26 10:31:21 +08:00
简单的说楼主因为用英语跟老外对话了几段就膨胀高潮了,把这毫无讨论价值的问题搬到这儿来秀
lufficc
2016-09-26 10:53:09 +08:00
yytsjq
2016-09-26 10:58:46 +08:00
@Clarencep Nginx 可以通过相关模块直接操作 Redis/Memcached 等客户端,如果有缓存的话,则直接跳过了 PHP/MySQL 了:

https://github.com/openresty/srcache-nginx-module#caching-with-redis

如果使用 Lua redis 的话,效果更好:
https://github.com/openresty/lua-resty-redis
shyling
2016-09-26 11:02:55 +08:00
没有特别的必要
ipconfiger
2016-09-26 11:32:30 +08:00
博客, 静态化就好了, 再改一下输出客户端的 expire, 要是不怎么修改的话, 你改成 1 年, 第二次访问网络都不走, 你再 redis 都没这个快
Clarencep
2016-09-26 12:11:46 +08:00
@yytsjq 涨姿势了。 如果这样直接把 redis/memcache 集成到 nginx 中,那肯定会比访问静态文件快。 可是偶的 VPS 只有 512M 怕开不起 redis/memcache...
Clarencep
2016-09-26 12:17:52 +08:00
@charove 你的坐标是哪里?通过啥宽带访问的?可能是 https 认证得比较慢 -- 没钱,所以用的某通的免费证书。 换用 http 访问试试呢: http://www.clarencep.com
Clarencep
2016-09-26 12:20:02 +08:00
@charove 奇怪,就是 https 也不应该 10 秒打开的呀 我本地是 10~50ms ,这个评测也是还蛮快的: http://www.mmtrix.com/evaluate/result/testid/fa521d2ec2df456a55a3f43ce0d8ff3c
Lcys
2016-09-26 12:22:44 +08:00
用 redis 文章页面打开速度明显提升
lufficc
2016-09-26 15:32:04 +08:00
@yytsjq 长知识了
firefffffffffly
2016-09-26 15:55:49 +08:00
其实问题关键确实是在开源上,如果是自己练习或者 just for fun 啥的,想咋弄都行,不过这样也失去了开源的价值。如果是选择了开源,就得多方面考虑性能和速度之外的问题,考虑代码是给别人使用的,比如易用性和复杂度,比如清晰的结构和拓展性。
az8525722
2016-09-26 17:33:20 +08:00
个人博客辣鸡到
SmiteChow
2016-09-26 17:43:19 +08:00
缓存的目的为了快,你够快就不用加。当然你练手除外
lslqtz
2016-09-26 18:03:45 +08:00
上硬数据直接镇就行了,不过就实际来说,我用 memcache 和不用没区别。
还是静态缓存好
wizardforcel
2016-09-26 20:02:41 +08:00
你就说用来存放全文搜索的索引。
hengxin196
2016-09-26 22:20:25 +08:00
@qgy18 好快
yanzixuan
2016-09-27 09:19:06 +08:00
默默在自己的 flask BLOG 上加了一个 FLASK_CACHE...
HypoChen
2016-09-27 18:08:32 +08:00
lufficc
2016-09-28 00:39:57 +08:00
@HypoChen 这个是啥?
LokiSharp
2016-09-28 09:06:10 +08:00

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

https://tanronggui.xyz/t/308824

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

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

© 2021 V2EX