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

6

8

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

Flashover answered 13/5, 2011 at 7:47 Comment(3)
I'm not sure what do you mean by that. The question was meant more like if the framework could represent a problem when it comes to scalability. (not if it would help). Is there a framework specialized for scalability?Flashover
Not that I know of. None of the major frameworks aids e.g. distributed code or performant queries (would also help if you define what you intend instead of letting us guess). See also previous lari fari discussions on that #132556Pinckney
Why even bother with PHP. It's on the way out. Other languages like Python, Ruby, C# have better tools for developing websites.Cark
P
7

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.

Proviso answered 13/5, 2011 at 7:51 Comment(2)
I haven't used any frameworks so far (made everything by hand). But this web site really has to be flawless (at least i would like to come near that :)). It's a big project, team is small and time is limited, so i thought that this time it would be a good idea to implement a framework. It brings along some concepts that are based on good practices so I wouldn't have to deal with them. Later when the page grows i can replace those concepts with more suitable if necessary.Flashover
By Frameworks I am referring to PHP and crossing over to pre-compiled DLL's like eBay and by engines I'm reffering to MYSQL. Jumbonormous websites generally don't use MYSQL but instead use high end performance based database engines.Proviso
H
3

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.

Haberdasher answered 13/5, 2011 at 8:32 Comment(2)
Yes, i've read about those "huge web site architectures" on highscalability.com, but i think it's impossible to start this way on this stage. In this phase we should probably build a simpler architecture, but leave the doors open. So we can optimize it step by step later.Flashover
You make it, you own it. Do you expect to write your own libraries, document them and maintain them. A framework lets you focus purely on the business logic and forget about the other bullshit. Sure there are some bad frameworks and template languages around. But sometimes you do get better tools with a framework. Good documentation, integrated unit testing, built in caching and form libraries, and a community who can help you out, because your code will be standardized somewhat. It would simply be a waste of time writing your own framework. I'm sure facebook didn't optimize prematurely.Cark
O
1

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.

Opprobrious answered 13/5, 2011 at 7:53 Comment(2)
Implementing a framework shouldn't be so big problem... Or? Am i missing something? I have quite some lines of code behind me, and i was never afraid of using/learning something new.Flashover
@Cartoonle: It doesn't have to be a problem if you feel up to it. There is nothing I enjoy more than writing an API or a framework from scratch, anything other than that is basically fixing and updating legacy code. But there are benefits in avoiding coding some tasks which have already reached certain maturity in well known frameworks. And at some point when you need a certain feature quickly, you can benefit from using existing toolkits, plugins, and other publicly available stuff.Opprobrious
R
1

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.

Rives answered 13/5, 2011 at 8:15 Comment(2)
I've already decided to go stateless...Flashover
Sorry, I did not read your post properly - so I guess its a matter of choosing a framework which provides the best hooks into cloud storage.Rives
O
0

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

Ostrogoth answered 13/5, 2011 at 7:56 Comment(4)
Regarding security, it is usually quite contrary. Security through obscurity is considered weaker than using publicly available solutions.Opprobrious
@Groo, but it is fact that ALL open source CMS (Joomla, drupal), open source forums (SMF) are more open for hackers rather than if you implement your own code (fully tested) from scratch.Ostrogoth
What about PHPulse? It calls himself the fastest...Flashover
+1, Ummar has good point that open source is open for hacking.Dublin
C
-1

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/

Cark answered 14/5, 2011 at 6:18 Comment(3)
I've heard good things about Django, but i've never used Pyton before, so it's probably not the best option for me.Flashover
Interesting that you hate CodeIgniter this much ... many are recommending it and it has everything i need (i think). Which PHP framework would you recommend ove CodeIgniter?Flashover
See my reply above. Basically I think you should checkout django properly before dismissing it as python hype, but I've also provided some PHP alternatives.Cark

© 2022 - 2024 — McMap. All rights reserved.