Jun 27, 2011

网页应用设计工具和原则

前端 (html, css, js):

Firefox + Firebug + Web Developer
ColorZilla 提取颜色


后端
nginx + uwsgi+django (nginx + fastcgi+django in windows)
数据库 mongodb

如果应用计算量大,不应该包含在 wsgi+django中(因为服务器可能根据需要kill/spawn processes)
应使用任务队列,比如 celery。
甚至很多任务,都可以使用队列。参见
Queue everything and delight everyone. The key is that it's all about messaging, not publishing.

功能齐全和快速是不同的话题。如何做到反应快速,而又功能齐全,关键在于messaging。

  • 用户提交内容时,快读反应,让用户满意,提交更多内容
  • 检索内容时,快速反应

你的网站可能功能齐全,当用户生成内容时,要发布到个人私人页面,公共页面,会和许多元素交叉引用,比如tag,feed,会更新到他的朋友的页面,会更新到微博等等。但是这些功能所有都要完成,用户要等好久。因此要挑出最重要的功能,快速完成给用户反应,其他都是放在任务队列中。

To make the person who's submitting something happy, offer feedback visible in their own personal context in under 50-200 milliseconds. (That is, less than half-a-second at worst, in people terms.)

The next person to delight is someone following the first person's published content—and humanly speaking, delays of tens of thousands of milliseconds can be acceptable here. (That is, 1-10 seconds at worst, in people terms.)

Finally, you can start worrying about strangers, allowing the content to propagate to tag pages, keyword tracking pages, and other public views—and I'd assert that delays of hundreds of thousands of milliseconds are acceptable here. (That is, 1-2 minutes at worst, in people terms.)

And, in the end, that's really the purpose of a web-based content creation interface—accepting something as quickly as possible to make the user happy enough to continue submitting more. The other part of the user interface, retrieval, serves simply to get the original content distributed as fast as can be reasonably expected.

Now, preparing for fast retrieval is another story. The flip side to processing queues are message inboxes—expect content duplicated everywhere and fetched simply, rather than using cleverly expressed SQL joins that bring a system to its knees.

理解:
比如用户查询family tag下的内容,系统进行数据库查询,选择带family tag的内容,这样反应会很慢。更好的做法时,这个(查询)结果已经在那儿了,随时可用。所以在用户提交内容时,如果带 family tag,就往 family tag 结果添加一个条文,如果用户删除某一个内容的family tag。就更新结果。

task Queue
  • celery
  • cue(轻量)
  • django-tasks(适合很少的几个任务,运行很久的)
  • GAE task queue

参考
1. 网站架构总结

0 comments: