我们应该使用 PHP 框架来构建高可扩展性的网站吗?

发布于 2024-11-07 03:47:14 字数 213 浏览 3 评论 0原文

我们正在准备建立一个具有高规模潜力的网站。如果规模到来,我们希望做好准备!我们决定使用 PHP、Apache 和 MySQL。我们应该使用某种 PHP 框架(PHPulse、CodeIgniter、CakePHP、Zend...),还是最好从头开始构建一切? 网站的性质将类似于 Facebook,但主要是文本数据(图像、视频不多)。网站将托管在云上。

你会推荐什么?

问候...

We are preparing to build a web site with high scale potential. If the scale comes, we want to be ready for it! We decided to use PHP, Apache and MySQL. Should we use some kind of PHP framework (PHPulse, CodeIgniter, CakePHP, Zend,...), or it's better to build everything from the scratch?
The nature of web site will be similar to Facebook, but there will be mostly text data (not many images, videos). Web site will be hosted on cloud.

What would you recommend?

Regards...

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

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

发布评论

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

评论(6

落花随流水 2024-11-14 03:47:14

这个问题已经被问过很多次了。普遍的共识是永远做你能做的事。从一开始就不必担心它的可扩展性太大,只需稍微记住它即可。尝试从一开始就构建过于可扩展的产品会让人筋疲力尽,而且您很可能会放弃。

如果您确实因为大量流行而开始遇到问题,那就太好了!然后,您就足够受欢迎,并且希望赚到足够多的钱,开始不必担心支付更昂贵的托管和更高端的编程/数据库框架和引擎的费用。

This question has been asked many times. The general consensus is always do what you can do. Don't worry about making it too scalable from the start, just keep it in your mind slightly. Trying to build too scalable from the start is exhausting and you would most likely give up.

If you do start getting problems due to massive popularity, thats great! You are then popular enough and hopefully earning enough to start having to worry about paying for more expensive hosting and higher end programming/database frameworks and engines.

清风疏影 2024-11-14 03:47:14

从头开始构建它。控制每一点都有助于优化。 Facebook 甚至控制其 php 编译器: http://developers.facebook.com/blog/post/358 /

不要使用框架,因为 PHP 已经是一个框架和一个模板引擎: http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html

使用一些缓存库,如 memcached。我不确定你是否可以在云端使用它,或者云端可能提供自己的缓存系统。

Build it from scratch. Controlling every bit helps while optimizing. Facebook even controls its php compiler: http://developers.facebook.com/blog/post/358/

Do not use a framework since PHP is already a framework and a template engine: http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html

Use some caching library like memcached. I'm not sure if you can use it on the cloud, or the cloud may provide its own caching system.

柏拉图鍀咏恒 2024-11-14 03:47:14

如果您知道很快需要对其进行扩展,那么最好使用现有的经过验证的框架,而不是从头开始构建自己的框架。与其说是为了可扩展性,不如说是为了简化以后的工作,并对样板代码的功能足够好有更大的信心。

另一方面,如果您从未使用过任何上述框架,您可能会考虑权衡跨越初始学习曲线所需的时间。

If you know you will need to scale it soon, then it's a good idea to use existing proven frameworks, rather than building your own from scratch. Not so much for the scalability, but more to simplify your work later, and have greater confidence that boilerplate code functions well enough.

On the other hand, if you have never used any of the mentioned frameworks, you might consider weighing the time you will need to overpass the initial learning curve.

花辞树 2024-11-14 03:47:14

比平常付出更多的努力来确保您的域层与其余代码尽可能松散耦合 - 这样,如果您发现其他层存在问题,您应该能够敞开大门进行更改。

一定要使用框架来启动和运行,但要注意使用他们自己的 CRUD 实用程序(CI,我正在看着你)。

如果您决定使用 ORM 解决方案,那么也许选择一个能够与多种框架很好地配合的解决方案。

Put more effort than usual into making sure your domain layer is as loosely coupled as possible from the rest of the code - that way you should be able to leave the door open to change if you identify problems with the other layers.

Use a framework by all means to get up and running but beware of using their own CRUD utilities (CI, I'm looking at you).

If you decide you want to use an ORM solution, then maybe choose one that plays nicely with a number of frameworks.

陌伤浅笑 2024-11-14 03:47:14

如果你从头开始构建每一个东西,那么肯定会花费时间,但只有你会知道代码的内部逻辑。相反,如果您使用框架,您将获得快速开发,但在这种情况下,您在对任何人开放的代码上创建网站意味着更多的机会被黑客攻击。每种方法都有自己的优点和缺点。无论如何,你可以查看最好的 php 框架 PHP 10 佳框架。我会推荐 Code Igniter

If you build each and every thing from scratch then for sure it will take time but only you will know the internal logic of code. In contrast if you use a framework you will get quick development but in that case you are making your website on that code which is opened for any one means more chances to be hacked. Each method has its own pro and corns. Anyway you can check out best frameworks of php Top 10 frame works of PHP. And I would recommend Code Igniter

黑色毁心梦 2024-11-14 03:47:14

我会说不,因为今天有更好的语言。 Python、Ruby 和 C# 拥有比 php 更好的命名空间和开发工具。

然而,你真正的问题不是语言。它将是数据库层,因为这将更加集中。您可以使用memcached来减少数据库的负载。如果您使用 ORM,请检查它是否具有运行直接查询和运行批量插入的所有能力,或者使用联接而不是延迟加载查询来获取相关对象。

您还应该使用队列来加速页面加载。如果您有可以在页面请求之外完成的缓慢操作,则将它们推入队列并稍后处理它们,可能在不同的服务器上。电子邮件和图像大小调整就是一个很好的例子。

如果您想要一个真正可扩展的 Web 应用程序,您必须跳出 Apache、MySQL 的圈子,开始使用 Nginx 和非关系数据库等工具。

目前,最好的做法是在问题出现之前就不要过于担心。只需确保您选择的任何框架都是松散耦合的,以便您可以执行诸如切换数据库层之类的操作。像瘟疫一样避免使用 codeigniter,它根本不是模块化的,没有 ORM 和一个非常糟糕的表单库。我推荐 Django(python),有很多公司为其提供云托管。我见过一家商店从 PHP 转向 Python,他们最终非常喜欢它。不要认为您必须局限于 PHP,尤其是当您选择托管时。

编辑、回复Cartoonle
姜戈。但如果你真的想要 PHP,也许可以选择 Symfony,但它以速度慢而闻名。 Kohana 与 CI 类似,但更多的是社区驱动和 OOP,因此 codeigniter 的一些主要缺陷早已在 kohana 中得到了解决。我也听说过有关蛋糕的好消息,但从未亲自品尝过。至于 codeigniter,是的,很多人喜欢它,它很简单,但缺乏很多好的软件模式,而有利于丑陋的快捷方式。我用它工作了一年,过了一段时间,团队中的每个人都同意我们重新发明轮子太多了,需要其他东西。当你使用它一段时间后,问题就开始出现。我们争论了一段时间,最终最终选择了 Django。这是一个艰难的决定,但带来了更高的生产力。再加上谷歌使用它,我认为这说明了很多。

说实话,Python 是 comp sci 101 课程和专业中唯一使用的语言之一。 Python 的目标之一是让计算机科学教学变得简单。这并不那么可怕,打开一个终端,输入 python 并玩一玩。还有很多不错的工具,比如 pip,它类似于 PHP-pear,但除了精彩的 python 包存储库之外,还可以与 git、gzip、hg 和许多其他格式一起使用。
还有一堆针对它的软件包,我在 PHP 中确实没有看到那么多。 http://djangopackages.com/

至少给它一个机会来完成教程,这大约需要 2 个小时。它带有一个内置的网络服务器,因此除了 python 本身之外不需要任何设置。

http://docs.djangoproject.com/en/1.3/intro/overview/

I would say no because there are better languages today. Python, Ruby and C# have much nicer namespacing and development tools than php.

Your real problem however will not be the language. It will be the database layer, since this will be a lot more centralized. You can use memcached to reduce the load on the database. If you're using an ORM check that it has all the ability to run straight queries and run bulk inserts or use joins rather than lazy loaded queries to get related objects.

You should also use queues to speed page loads up. If you have slow operations that can be done outside of the page requests then push them into a queue and process them later, possibly on a different server. Emails and image resizing is a good example.

If you want a truely scalable web application you will have to step outside the Apache, MySQL bubble and start using tools like Nginx and non-relational databases.

For now, what it is best to do, is not worry too much about the problem before it even exists. Just make sure whatever framework you choose is loosely coupled so you can do things like switching out the database layer. Avoid codeigniter like the plague, it isn't modular at all and has no ORM and a really poor form library. I would recommend Django(python), there are a number of companies which do cloud hosting for it. I've seen a shop switch from PHP to Python and they ended up liking it a lot. Don't think you have to be locked into PHP, especially when you are choosing the hosting.

Edit, reply to Cartoonle
Django. But if you really want PHP, maybe Symfony, but it is known for being slow. Kohana is like CI, but more community driven and OOP, so some of the major flaws of codeigniter have been solved long ago in kohana. I've also heard nice things about Cake, but never tasted it myself. As for codeigniter, yes many like it, it is simple, but lacks a lot of good software patterns in favor of ugly shortcuts. I worked with it for a year, after a while everyone on the team agreed we were re-inventing the wheel too much and needed something else. When you've worked with it for a while the problems start to bubble up. We debated for a while, eventually ended up with Django actually. Was a hard decision but paid off with higher productivity. Plus Google use it, I think that says a lot.

Seriously python is one of the only languages used in comp sci 101 courses and professionally. One of the goals of python was to make teaching comp sci easy. It's not that scary, open up a terminal, type in python and have a play around. There are a lot of nice tools around for it too, like pip, which is like PHP-pear but also works with git, gzip, hg and a number of other formats besides the wonderful python packages repository.
There is also a heap of packages around for it, which I really don't see nearly as much with PHP. http://djangopackages.com/

At least give it a chance by doing the tutorial, which takes ~2 hours. It comes with a built in web server so there is nothing to setup besides python itself.

http://docs.djangoproject.com/en/1.3/intro/overview/

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