使用 Php 开发可扩展的网站

发布于 2024-09-17 18:53:25 字数 250 浏览 8 评论 0原文

我将使用 Php(Zend 或 Yii 框架)开发一个社交+专业网络网站。我们的目标是每分钟超过 5000 个请求。我有使用 MVC 框架开发高级网站的经验。

但是,这是我第一次开发一些考虑到可扩展性的东西。因此,如果有人能告诉我有关我应该寻找的技术的信息,我将非常感激。

我读过有关 memcache 和 APC 的内容。我应该寻找哪一个?另外,我应该使用单个 Mysql 服务器还是主/从组合(如果稍后,那么为什么以及如何?)

谢谢!

I am going to develop a social + professional networking website using Php (Zend or Yii framework). We are targeting over 5000 requests per minute. I have experience in developing advanced websites, using MVC frameworks.

But, this is the first time, I am going to develop something keeping scalability in mind. So, I will really appreciate, if someone can tell me about the technologies, I should be looking for.

I have read about memcache and APC. Which one should I look for? Also, should I use a single Mysql server or a master/slave combination (if its later, then why and how?)

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

维持三分热 2024-09-24 18:53:25

您可能希望将站点构建为至少使用主/从复制系统。您不一定需要首先设置复制 mysql 框,但您希望设计应用程序,以便数据库读取使用与写入不同的连接(即使一开始两个连接都连接到同一数据库服务器)。

您还需要仔细考虑您的缓存策略。我会考虑 memcache,尽管使用 Zend_Cache 您可以尽早使用基于文件的缓存,并在需要时交换 memcache。除了记录缓存之外,您还需要考虑(部分)页面级缓存,以及您想要在那里规划/实施什么样的策略。

您还需要仔细计划如何处理用户生成媒体的存储和检索。您将希望能够轻松地将这些内容从主服务器移至专用的设备上以提供静态内容或某种 CDN(内容分发网络)。

另外,考虑一下您将如何处理会话管理,并确保您不会做任何会阻止您将来使用非基于文件的会话存储((专用)数据库或内存缓存)的事情。

如果您仔细思考并抽象数据存储/检索,您将朝着一个好的方向前进。

You'll probably want to architect your site to use, at minimum, a master/slave replication system. You don't necessarily need to set up replicating mysql boxes to begin with, but you want design your application so that database reads use a different connection than writes (even if in the beginning both connections connect to the same db server).

You'll also want to think very carefully about what your caching strategy is going to be. I'd be looking at memcache, though with Zend_Cache you could use a file-based cache early on, and swap in memcache if/when you need it. In addition to record caching, you also want to think about (partial) page-level caching, and what kind of strategies you want to plan/implement there.

You'll also want to plan carefully how you'll handle the storage and retrieval of user-generated media. You'll want to be able to easily move that stuff off the main server onto a dedicated box to serve static content, or some kind of CDN (content distribution network).

Also, think about how you're going to handle session management, and make sure you don't do anything that will prevent you from using a non-file-based session storage ((dedicated) database, or memcache) in the future.

If you think carefully, and abstract data storage/retrieval, you'll be heading in a good direction.

缺⑴份安定 2024-09-24 18:53:25

Memcached 是一个分布式缓存系统,而 APC 是非分布式的,主要是一个操作码缓存。

如果(且仅当)您的网站必须驻留在不同的网络服务器上(负载平衡),您必须使用 memcache 进行分布式缓存。如果没有,就坚持使用 APC 及其缓存。


关于MySQL数据库,我建议使用可以根据需求自动缩放的gridhosting。

Memcached is a distributed caching system, whereas APC is non-distributed and mainly an opcode cache.

If (and only if) your website has to live on different webservers (loadbalancing), you have to use memcache for distributed caching. If not, just stick to APC and its cache.


About MySQL database, I would advise a gridhosting which can autoscale according to requirements.

っ左 2024-09-24 18:53:25

根据您网站的要求,数据库更有可能成为您的瓶颈。
MVC 框架往往会为了易于编码而牺牲性能,尤其是在 ORM 的情况下。不要依赖 ORM,而是对查询数据库的不同方法进行基准测试,看看哪种方法适合。您希望最大限度地减少数据库查询的数量,一次获取一大块数据,而不是执行多个小查询。

如果您发现您的 php 代码是瓶颈(在优化之前对其进行分析),您可能会发现 facebook 的 嘻哈很有用。

Depending on the requirements of your site it's more likely the database will be your bottle neck.
MVC frameworks tend to sacrifice performance for easy of coding, especially in the case of ORM. Don't rely on the ORM, instead benchmark different ways of querying the database and see which suits. You want to minimise the number of database queries, fetch a chunk of data at once instead of doing multiple small queries.

If you find that your php code is a bottle neck(profile it before optimizing) you might find facebook's hiphop useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文