我现在正在开发一个用于实时和历史跟踪网络服务的大型后端系统。
我在 Python 方面经验丰富,打算将其与 sqlalchemy (MySQL) 一起使用来开发后端。
我没有任何开发强大且可持续的后端系统的主要经验,我想知道你们是否可以向我指出一些有关后端设计模式的文档/书籍?我基本上需要通过实时查询不同的服务(通过 HTML / SOAP / JSON)将数据提供给数据库,并保留该数据的历史记录。
谢谢!
I am now working on a big backend system for a real-time and history tracking web service.
I am highly experienced in Python and intend to use it with sqlalchemy (MySQL) to develop the backend.
I don't have any major experience developing robust and sustainable backend systems and I was wondering if you guys could point me out to some documentation / books about backend design patterns? I basically need to feed data to a database by querying different services (over HTML / SOAP / JSON) at realtime, and to keep history of that data.
Thanks!
发布评论
评论(2)
您能更准确地定义“后端”吗?通常,在 Web 开发中,我遵循 MVC 式结构,其中我的“前端”、html/css/js 和处理显示的代码与我的“后端”模型(业务对象和数据持久性;即数据库)。
我喜欢 Django 的模型/视图/模板方法:
http://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view- and-the-view-the-template-how-come-you-don-t-use-the-standard-names
但是,您还没有真正定义“后端”的含义,因此很难提供设计建议模式。你说你有Python经验,你以前开发过数据库驱动的Web应用程序吗?
更新
根据您的评论,我无法提供太多帮助,因为我没有太多进行此类“后端”的经验。然而,考虑到您如何从网络获取资源,您的延迟/吞吐量将会相当高。因此,为了提高整体效率,您将需要能够以相当高的并发性运行多个线程或进程的东西。我建议您查看此线程上的答案(并搜索类似的答案):
并发下载 - Python
具体来说,我发现递归 Web 服务器的示例及其后面的示例可能是解决方案的一个很好的开始:
http://eventlet.net/doc/examples.html#recursive-web-crawler
至于采用这个想法,然后将其转变为一个强大/连续的过程,这将取决于您的平台上有很多信息以及您的错误处理能力如何。基本上:
保持事物“健壮”的最佳方法之一是使它们尽可能简单(而不是简单化)。如果您所做的只是从网络中获取信息,以某种方式解析它,然后将该信息存储在数据库中,那么请尝试使过程保持简单。不要为了使其更加健壮而增加不必要的复杂性。如果您最终得到了一个 200 行的脚本,可以满足您的需求,那就太棒了!
Can you define "backend" more precisely? Normally, in web dev, I follow a MVC'ish structure where my "front-end", html/css/js and code dealing with displaying either, is loosly coupled with my "backend" model (business objects and data persistence; i.e. database).
I like Django's Model/View/Template approach:
http://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names
But, you haven't really defined what you mean by "backend" so its hard to give advice on design patterns. You said you are experienced in Python, have you ever developed a database driven web application before?
update
Based on your comment, I won't be able to help much as I don't have much experience doing "backends" like that. However, seeing as how you are pulling in resources from the web, your latency/throughput is going to be pretty high. So, in order to increase overall effectiveness, you are going to want to have something that can run multiple threads or processes with pretty high concurrency. I suggest you check out the answers on this thread (and search for similar ones):
Concurrent downloads - Python
Specifically, I found the example for the recursive web server and the example following it to probably be a very good start on your solution:
http://eventlet.net/doc/examples.html#recursive-web-crawler
As for taking that idea and then turning it into a robust/continuous process, that's going to depend a lot on your platform and how well you do error handling. Basically:
One of the best ways to keep things "robust" is to make them as simple (not simplistic) as possible. If all you are doing is pulling in info from the web, parsing it in some way, and then storing that info in a DB, then try to keep the process that simple. Don't add unnecessarily complexity in an effort to make it more robust. If you end up with a 200 line script that does what you want, great!
使用 Apache、Django 和 Piston。
使用 REST 作为协议。
编写尽可能少的代码。
Django 模型、表单和管理界面。
为您的资源提供活塞包装。
Use Apache, Django and Piston.
Use REST as the protocol.
Write as little code as possible.
Django models, forms, and admin interface.
Piston wrapppers for your resources.