开发者

Should we use PHP framework for a high scalable web site? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_运维问答 Closed 11 years ago.

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...


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.


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.


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.


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.


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


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜