I have heared that PHP is not good for large websites althogh I do not know what is the meaning of large websites in this case, is it something like Facebook for example? Any way, is it true that PHP does scale with large websites?
PHP is as scalable as the developer is proficient.
Languages, libraries and frameworks don't scale. Architectures do.
Yes, maybe not as inherently as some others (I'm a PHP developer).
http://swik.net/PHP/Major+Sites+that+use+PHP
Facebook is the biggest example, but there are many other ones as well.
I'm going to differ with my counterparts here. As a language, nothing about PHP is built for scalability. Any language can be extended for that, and PHP has far more than its fair share of tools to do it, but as far as built-in tools to support that need, it has none.
Which is exactly what makes it a great choice.
You see, with the lack of built-in high-level web tools, it allows others to built unique solutions to the problems. Just about every major advancement in other languages has been duplicated for PHP. There is not a single tool out there in some other language that isn't matched or beat by something in PHP.
And after all that, those built-in limitations help foster good development practices and security-conscious designs. It forces we devs to learn the theory behind the techniques we apply and cuts-down on the misapplication of those principals.
Anyway. /lovemaking-with-php
PHP is fairly scalable, and certain frameworks such as Zend increase the likelihood of successful scalability.
The biggest obstacle to scalability in PHP has less to do with the language or its framework and more to do with programming and system architecture in general. Developing a good, scalable system is difficult even for the masters.
A programming language cannot always be pinpointed as THE culprit in problems related to performance. How it's used and what environment it's running in should be considered and must go thru any honest-to-goodness performance audit. PHP is definitely scalable, but the more important things you should consider: application efficiency, disk I/O, bandwidth management, etc. You may have the perfect high-traffic capable application, but try running it on an old PC or a dial-up modem.
It depends on your application architecture not programming languages. If your architecture and design is optimised your application will perform very well on large scale. And also depends on your servers.
Related
I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.
Python's a very good language to learn for a number of reasons, including its clear syntax, its excellent standard library, its multi-paradigm support, and the helpful community that surrounds it.
However, scalability has more to do with your system's overall architecture than with the programming language you choose. Often, the database is the main bottleneck, and the performance of the programming language that's talking to the database will not have much impact on overall site performance.
I don't think rewriting in Python will help you that much, it is very hard to say anyway without knowing your exact scalability problem. When it comes to real scaling issues, every problem is unique and there is no one true solution.
That being said, Python is an interesting language, and if you've time on your hands and want to learn something, it sounds like a good idea to look at it closely. I would also look at JavaScript more closely though, be it using NodeJS (which is also pretty damn fast for some things) or just in a browser, it's a language that is not going away anytime soon. If you're a web developer, you can't know enough JS imo.
For web applications I would personally learn Python after PHP, but if your a Windows fan consider ASP.NET.
I cant comment on the difference in scalability of a website but i have had very positive experiences using frameworks such as django for small time websites. I really love the separation of code and templating (i know you can do this somehow with php too).
Many conversations on frameworks tend to discuss ease of use and speed of development. These issues are important but they tend to come from developers who are creating new low traffic projects over and over for different clients. It is important in that situation to be able to knock out a solid solution for the client in as little time as possible. I myself have operated in this area for many years and have used many MVC frameworks with much successes.
But what about when you are working on a single high traffic application for several years? Now ease of use and speed of development start to take a back seat to scalability and speed. It doesn't matter how easy it is to use or how fast you can write code if the application won't function because of speed and scale.
My question to any large scale developers out there is, are frameworks still useful in this situation and if so which have been used successfully in large scale production situations?
common frameworks: zend, symphony, codeignitor, cakephp
When it comes to large applications, it's not the framework you should be concerned about, it's the database.
First decide which database you going to use, then look for a framework that has good support for that database. If you want your app to scale to unlimited size and still be fast, you should eliminate Mysql as an option right from the start.
Look for NoSQL solution, find the one that you like. Cassandra, MongoDB, CouchDB are the top 3 choices, but there are others. All of these are fairly new, but some of the biggest sites in the Internet are using them. Do your research, choose database, then choose framework.
I don't know most of the frameworks, I looked at Zend and Symphony2, both support MongoDB, both are pretty fast. I would look at either one of these 2, no reason to look anywhere else.
But really, if you plan on writing a really large application you should really write your own code and don't use frameworks. This way you will have only the functions that you need and none of functions you don't need. Remember most frameworks offer you a lot more functionality then you really need. Unnecessary functionality usually slows down your app.
if you want a fast app, then it has to be lean, only do what you need and nothing else.
symfony is used by Yahoo on it's Bookmarks and Answers site.
You should note they ditched the ORM so the database remains as the main concern for scaling (as Dmitri stated), you can read more about it here.
Dailymotion is also using symfony.
My question to any large scale developers out there is, are frameworks still useful in this situation and if so which have been used successfully in large scale production situations?
I've seen symfony-based applications successfully scale up to many thousands of users so is a strong candidate.
The creator of php liked codeigniter(in the past) the best, because it is the fastest framework when he benchmarked it. You can listen to video about that over here.
To add on to what the others have already said:
You can start off with any framework as your starting point. As your application gets bigger (and I mean, BIG), you can start modifying the framework and customizing it to your application's specific needs. After all, frameworks are a general solution to most problems.
You should pick whatever framework you're most comfortable with, and tailor it to your needs if your application ever grows extremely large. No point worrying about a million visitors when you don't have them yet.
WordPress.com is about the 22nd most popular website in the world and it runs on (you guessed it) WordPress, which is a framework with a large amount of overhead. So it definitely is possible.
Whether you are using a framework or not, you end up working on the same kinds of problems as your site gets to massive scale. Building on top of a framework means that you'll have one less problem (no custom framework to write) while working on other scaling issues. However, you may have to extend or tweak that framework to work with whatever technology you need to scale.
And in general, what I would recommend is that you don't blaze your own path. Find an app or site that is comparable to the one you are building and figure out what technology and techniques they used to build that site (many like WordPress.com, Twitter, Google projects are well documented or have chatty developers) and use the same technologies and techniques. You'll benefit from them figuring everything out ahead of time.
We are planning to develop a email marketing system. We are trying to decide if we shall use LAMP stack or MS.NET with SQL server.
I understand MS.NET is faster/easier to develop and has support from MS but in the long run it will cost more considering the licensing cost.
I guess LAMP will cost less and can also be scaled as good as MS.NET and SQL server architecture.
Can you pl provide your valuable feedback considering following criteria:
Overall development and maintainance cost
Scalability of software using PHP/MySQL and MS.NET/Sql Server
Speed of development and availablity of development tools.
...anything criteria you deem important.
Also, what do you think about hybrid approach of MS.NET and MySQL. It will give RAD (rapid application support) of .NET and reduce database licensing cost.
From my experience with web development...
You're probably looking at a slightly higher development and maintainence cost with .Net. Generally, hosting is more expensive for .Net (although there is a free version of MS SQL) as the underlying software is more expensive. Naturally, it depends what you consider expensive / too expensive at this stage in your business - but you can't beat the cost of Linux.
I believe that .Net has the potential for more efficient scalability but it's pretty much a subjective topic, as the scalability will depend on the way that the system is programmed, the quality of the code produced and many other factors. Realistically, this unlikely to be an issue until the system is very large.
Development speed will depend on what your programmers are more comfortable with. .Net has a nice set of built-in controls and some really nice commercial packages to really speed things up (Telerik controls for instance, though they are not cheap!). There are also a number of very mature frameworks for PHP that can drastically reduce development time - I personally like CodeIgniter (free). I believe the determining factor on this point really does depend on your coders and their skills / experience with the languages.
The free version of MS SQL is free up to some very reasonable limits - the sort of limits that, if you hit them, you should be making enough money that upgrading isn't a problem!
At the end of the day, you should discuss what everyone feels most confortable developing with - if you want clean / good code, you're much less likely to get that if you're also learning a new language as you go. You should also decide what your limits are for the other factors to determine if there is enough of a difference that will realistically impact on your product - for instance you could try to compare performance between the two languages forever, but they're both almost certainly fine for your needs - so don't worry too much about it!
I work in both environments. Personally I lean towards PHP. I find that development time is a lot faster because the community (Open Source) is so much bigger. I never have to recreate the wheel. MS has a very cool IDE with a lot of drag and drop functionality but to be honest those controls have limitations and again I'm personally moving more towards a jQuery solution.
Obviously, maintenance and support is a huge issue. This would depend on the project. There are experts out there that you could hire to help if you needed. Some very big sites run on PHP and mySql.
As others have mentioned above, your team might be the final answer to your question. If you only have PHP programmers then I would use PHP. If you have .Net programmers then I would lean towards .Net... If you are hiring out of the box, PHP programmers are usually cheaper (unfortunately).
Just my 2 cents.
There is a free version of SQL server, but of course there is no support for it, so maintenance is entirely on your IT staff, just as it would be with LAMP. Both are equally scalable for most people's needs. PHP has some framework options which can make it just as easy to get an initial system up and running, just as you would with .NET, but no matter which language you choose, the speed of development is all going to be based on your development team.
Its not a fair comparisson if you compared .net with ms sql vs. php with mysql.
Compare using mysql in both, if you are willing to use mysql with php, why not with .net?
That aside, pre-existing skills in the team will make a Huge difference. This applies for both the development aspect and the infrastructure aspect (managing/monitoring the servers).
In my mind, the great advantage of ASP.NET over PHP is the ability to develop code that is shared across web and non-web apps. If you have complicated business logic, that needs to be implemented on your website and on desktop apps or background services, you can put in a .NET assembly and use it any any of them.
The closest platform I can think of that offers similar capabilities is server-side Java. Php simply can't do it.
Of course, you could implement the web UI in PHP, and implement the business logic in web services implemented in .NET or Java...
I build database-driven web sites. Previously I have used Perl or PHP with MySQL.
Now I am starting a big new project, and I want to do it in the way that will result in the most responsive possible site.
I have seen several pages here where questions about how to optimize PHP are criticized with various versions of "it's not worth going to great lengths to optimize PHP since it's an interpreted language and it won't make that much difference".
I have also heard various discussions (especiallon on the SO podcast) about the benefits of compiled vs. interpreted languages, and it seems as though it would be in my interests to use a compiled language to serve up the site instead of an interpreted language.
Is this even possible in a web context? If so, what would be a reasonable language choice?
In addition to speed one benefit I forsee is the possiblity of finding bugs at compile time instead of having to debug the web site. Is this reasonable to expect?
What you can do is what multiple heavy-traffic websites do (like Facebook or Twitter), aka write your "CPU consuming" algorythm in a C-plugin.
For example, you could write a PHP extension if you plan to use PHP, or a Ruby extension if you plan to use Ruby / Ruby on Rails, etc.
That way, you can keep your streamline code simple and easy to maintain (it might be way harder to handle request from C rather than from PHP), while having a strong and solid background core (because it's compiled, and the compiler tells you what the issues are at compile time)
If you were going to build a new language... and you came up with all the semantics and it was complete, and you had some magic box that had a switch between making the language compiled vs. interpreted, the compiled version would be faster than the interpreted version.
Why? Because compiling brings your semantics down to a lower level on the machine which means it can executed much faster, whereas interpreting means the semantics of your language will translated by some thing (i.e. the interpreter) when the user actually uses your site.
Having said that... that doesn't necessarily mean that your site is going to 100% run faster on a compiled language vs an interpreted language. There are interpreters out there that are very fast nowadays for various languages (i.e. PHP), and there are even optimizers for interpreted languages that make them faster even still.
There are many other things that go into the performance of your site that are agnostic of the language you choose. Hardware setup, Database setup, Network topology, etc. These things can have a bigger impact on you. I would suggest measuring to be sure.
For me, finding bugs at compile time is a huge time saver, so I tend to prefer compiled languages which are strongly typed. It lets me get my work done faster, but that doesn't make it objectively the best option. Some people have no issue writing weakly typed code, and running test suites on them to verify their functionality, which I would think would work just as well.
IMHO it is quite a non-sense to write a complex web app using a compiled language, as it gives not benefits against a number of manageability problems.
There a lot of ways to rise up performances and scalability in a scripted language, both at language level and at system level, being the minor performances gain eventually available with a compiled language totally influential.
On the other side I find very useful to be possible to follow an agile development and bug hunting schema, simply changing your code and seeing the results.
Perl isn't an interpreted language: it is compiled to bytecode, so you pay the price of interpretation only when the perl executable is started. So when using it with Apache, don't use CGI but mod_perl.
Whatever you do, development time is probably going to widely exceed response time if you pick a language that isn't suitable to web programming or doesn't have good libraries to support what you need to do. E.g. I'd never pick C or C++. You don't want a web app that is blisteringly fast but buggy and 6 months late.
Tomcat is a common way to use compiled languages to deploy webpages, but before you go too far, seriously consider what your speed bottlenecks will be. There are a few main sources of slowdown in web applications:
Network latencies
Static media, especially images
Database queries
Server-side processing code
Client-side processing code
1 and 5 don't really have much to do with this question.
2 will be relevant if you have many images that vary from page to page. If that's the case, client browsers won't do such a good job caching, and each page-load will take some time. In this case, it is very likely that your server-side language won't be noticed, because the overhead from static media will dominate.
3 is likely to be a bigger factor than 4 for a lot of applications. If you have very little data, but you do a whole lot of processing, then 4 may dominate, but otherwise, 3 will dominate even if you're using an interpreted language.
People can ask "Why optimize php?" because the 2 and 3 are often more important anyway. Often, a good database caching framework is going to be a better (and easier) optimization.
There are lots of parts that goes into a web application. The time taken by the application layer doesn't need to be big. For a typical application, the biggest hogs would be in the webserver and in the database. Replacing PHP with a binary cgi isn't going to change this.
Furthermore, while the interpreted parts of PHP may be somewhat slow, that is only a small part of what goes on in the execution of a PHP script. All the functions that are provided as part of the language are implemented in native code. For example, when you call a function like preg_match, it will call out a native code library and let it do its work. This means that there is less actual interpretation going on than you might think.
There may be some cases where using a different language than PHP might be worthwhile, but those are special cases. In general, there is nothing to gain here.
The latency of the network is by far the greatest determining factor in this argument. In fact, network latency is so much of a factor that it renders language considerations rather unimportant from a performance issue. So...go with what you know. Use the language that you are most comfortable and most productive with and other considerations can be worked out as you go along. Now, that said, it's always fun to try new stuff and learning new things can become an obsession, so if the project is a personal one that allows you the opportunity to experiment, well, by all means.....
Why is PHP the most used programming language for a web based platform?
PHP:
is easy to learn;
has been around for ~15 years;
runs fairly efficiently;
is cheap to host; and
actually scales really well (some of the largest sites on the internet use it).
PHP is basically the ultimate grass-roots success story.
PHP is:
Built for the web, that is not an extension of an existing language like Perl.
Free of any default framework; this allows it to be fairly lightweight and powerful, a good example of the KISS (Keep It Simple, Stupid) principle.
Because software that values simplicity over everything else propagates faster.
Probably because PHP is easy to learn and it was really simple at first start. With the upcoming of OOP from PHP4 we cannot really say it's simple anymore but at least it tries to keep simple.
Plus from the start the language was really Web oriented, easy access to get/post variables.
You can also note the PHP community is really wide and Zend do a great job to make it a real concurrent of Java/Dotnet/all the others.
Perl/Python/Ruby are also good scripting language but they require some libraries to develop web application
While most CGI language extensions require you to write HTML/JS/CSS within that languages syntax, PHP is able to be used within the contents of an HTML file structure. For someone who doesn't really get the concept of CGI (like I did a while back), it's really nice and offers room to grow with libraries and a universally familiar syntax.
It's also a strategic isue to
choose PHP over Java/Ruby/...
Because you will find PHP
programmers every time, but it is
really difficult to get (cheap)
Java/Ruby/... programmers.
PHP has become the third most be
liked programming language. * **
Its Open Source.
Its old and therefore very stable.
Its the best documented language in the internet.
It has the most string functions (necessary for web/HTML programming).
It has a very huge community, you will find the answer for every PHP question in the internet (or ask stackoverflow).
Its the only language which was designed for the internet.
PHP is fairly easy to install and fairly easy to understand. For that matter, you don't even have to install it. Fifteen dollars a month (or less) will get you a PHP webhost at hundreds of hosting companies.
There are no shortage of "Build a website in 5 minutes with PHP" books. Therefore, it's often the first choice to new web developers or people who want to get something done quickly.
PHP certainly has it warts, but done properly, it can be a good solution as well. Despite its warts, it runs an awful lot of successful websites.
I think it is easy to learn, it is faster, it has lots of forums, it has lots of example codes, it has ...
A lot of emerging php framework like Symfony, Zend, and Cake make rapid development, good mvc design easy. A lot of extremely popular blogging software/cms's are built using php eg. Drupal, Wordpress, and Joomla!.