Django的社交网络 [英] Django for social networking

查看:88
本文介绍了Django的社交网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个相对广泛的问题,但是Django是否足够健壮以建​​立社交网络?我主要关注性能/速度。例如,对于用户群较小(少于10,000个用户)的网站,是否可以创建一个由Django支持的网站,其运行速度与Facebook相似?

I know this is a relatively broad question, but is Django robust enough to build a social network on? I am concerned mainly with performance/speed. For example, for a site with a small user base (<10,000 users), is it possible to create a Django-backed site that would perform at a speed similar to Facebook?

其潜在的弱点是什么,为了使其尽快运行,需要重点关注什么?

What are its potential weaknesses, and things that need to be focused on in order to make it as fast as possible?

推荐答案

其潜在的弱点是什么?为了使其尽快运行,需要关注的重点是什么?

"What are its potential weaknesses, and things that need to be focused on in order to make it as fast as possible?"

您可能会担心的一件事关于下一步,取决于您如何创建模型以及如何将它们彼此连接,您可能会遇到一个问题,即一个页面会生成许多很多许多查询。

The one thing you might be worried about further down the road is that depending on how you create your models and connect them to one another, you may run into an issue where a single page generates many, many, many queries.

如果您使用的模型涉及通用关系

This is especially true if you're using a model that involves a generic relation.

假设您使用的是 django-activity-stream 创建一个最近事件列表(类似于Facebook的新闻源)。 django-activity-stream基本上会创建一个通用关系列表。对于这些通用关系中的每一个,您都必须运行查询以获取有关该对象的信息。而且,由于它是通用的(即,您不是要为每种对象编写自定义查询),如果该对象具有自己要输出的关系,则您可能正在寻找类似40-100个查询的活动供稿仅有20-30个项目。

Let's say you're using django-activity-stream to create a list of recent events (similar to Facebook's News Feed). django-activity-stream basically creates a list of generic relations. For each of these generic relations you're going to have to run a query to get information about that object. And, since it's generic (i.e. you're not writing a custom query for each kind of object), if that object has its own relations that you want to output, you might be looking at something like 40-100 queries for an activity feed with just 20-30 items.

对单个请求运行40-100个查询并不是最佳行为。

Running 40-100 queries for a single request is not optimal behavior.

好消息是Django实际上只是一堆用python编写的类和函数。您在python中编写的几乎所有内容都可以添加到Django中,因此您始终可以编写自己的函数或代码来优化给定的请求。

The good news is that Django is really just a bunch of classes and functions written in python. Almost anything you write in python can be added into Django, so you can always write your own functions or code to optimize a given request.

选择另一个框架不会避免可伸缩性问题;

Choosing another framework is not going to avoid the problem of scalability; it's just going to present different difficulties in different areas.

此外,您还可以研究缓存,以加快响应速度并防止服务器负载。

Also, you can look into things like caching in order to speed up responses and prevent server load.

这篇关于Django的社交网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆