I'm thinking about using Zend for my new project.
But I'm worried about using too much system resources.
I'm on the $20 Linode VPS
Will it be worth it?
What resources are you worried about?
Size-on-disk you can predict easily.
For memory and cpu it is harder. You could say that there is always a balance: If you make a small app, you can probably do a better job to code everything yourself. Any framework will give you overhead. But the bigger it gets, the harder it gets to write good code yourself. A framework will help you, and in the end you will be better off using a framework just because of the better your code will be (assuming you use it correctly).
So it is a really hard question to answer, without specifics. Gut feeling does tell me you would not go too wrong by starting with Zend. I've seen a couple of smaller, not-to-high-end environments using Zend with success.
The big question is how much traffic are you seeing?
100 visitors a day?
1,000 visitors a day?
10,000 visitors a day?
I was running a Zend Framework site on a Rackspace Cloud server with similar specs to your $20 Linode VPS. It operated just fine, but I only had maybe 50 visitors a day.
Zend Framework uses an Autoloader so it's pretty lazy in the files that it loads into memory. I've found ZF to be pretty quick for a framework of its size.
As the others have said, it depends on the traffic that you're both getting and expect to receive over time. I have a basic vps for one project and it works fine, but that was after standard tuning of Apache and MySQL. This includes disabling unrequired services, adjusting logging and KeepAlive timeout, amongst other variables (Apache) and tuning various caches (MySQL)
There's a lot that you can do to tune Zend Framework - which I'm quite keen on. Check out the talk by Rob Allen from the PHP London 2011 Conference for some great information.
Related
I'm developing a website with Classic ASP (yeah, I know it's 2017!) and I have a pretty heavy script that has many db writes and reads while it runs.
(Basically, it's a web based soccer game, and that heavy script is the match engine that simulates the match events while the game actually occurs minute-by-minute, while 1 minute ingame = every 20 seconds in reality).
I'm working with Windows 2016 Server on a VPS Server with 8GB RAM, using MySQL.
I already have a version of this running, an old one, and now I'm developing a better one, much more functional.
I thought about developing that engine with PHP, mainly because it's gonna be easier for my purpose since it partially supports OOP, and that's a huge advantage here, as it makes it much easier to store and access data.
How would you recommend to do that?
From your experience, what's the best way to run PHP on IIS? (I know there are some kind of plugins that do that)
And, what else should I take in account?
Thank you for your time!
Yes, you can run PHP on IIS.
http://php.iis.net/
As per my understanding you can also try Zend Server community edition.
http://www.zend.com/en/products/server-ce/
It's free, it's reliable, good performance, and it has a web-based admin console.
I've been using CakePHP for a while now. It is very easy and great to work on projects of wide range. I've been doing most of heavy calculations and database access in controller function. And only using the views to display the data which user is interested in. It has been working great till now. And no problem has occured.
But I want to ask is that, "Is it a right way to work with a framework in PHP. Is there any other way i can minimize the time required to process the request.
Thank You.
APC
The easiest way to improve your performance is to use(install) APC. APC helps you improve performance by precompiling bytecode and store it in memory(memory is fast). If you are on a shared hosting provider you haven't got the luxury to do this, but then again if your site gets big and receives a lot of traffic you should move away from shared hosting. You should buy a VPS and if your site gets even too big for this you should buy decided machine for hosting. The final solution if you are getting really big you should run/buy a cloud system.
CACHE
Next you should CACHE your data in memory to speed up your site again using APC. If your site gets big and one box doesn't cut it anymore you should cache your data in for example redis or memcached. Some people also start with using redis/memcached from the beginning. For example redis(FAST => KICKASS) is also a very powerful in memory database.
Low hanging fruit
After that you should benchmark your site using a tool like for example siege and tackle the low hanging fruit(don't wast your time doing silly micro-optimizations) by using a tool like for example valgrind/calgrind. This video "Simple is Hard" from Rasmus lerdorf(PHP creator) explains how he achieves this.
CakePHP Benchmarks
As a sidenote I would also like to point out that Rasmus Lerdorf(PHP creator) performed some benchmarks on CakePHP(CakePHP 1.2.0rc2) in the past and experienced it was slow as hell(Could have changed because the benchmarks have been performed in 2008 or something). but I thought these slides where really interesting. Based on the slides I would recommend you to switch to Codeigniter(the lighter your framework is the better your performance is going to be) as your framework.
Zend Framework is a good framework but not very fast.
Can you tell whether it's worth using Zend Framework for highload projects, for example, for email marketing service that can inlude about ten or houndred thousand of users?
Is it possible to achive acceptable performance using Zend Framework?
Has anybody such an expirience?
Thank you very much.
For what I have seen, the definitive defense of Zend Framework performance and recommendations for performance optimization comes from Padraic Brady at:
PHP Framework Benchmarks: Entertaining But Ultimately Useless
In particular, note his four recommendations for performance optimization:
Don't use Zend_Application. While Zend_App is great for creating consistent complex bootstraps within a standardised structure, it doesn't come without a significant performance hit to baseline performance. A more direct bootstrap (typical of ZF until Zend_App arrived) is far faster and can also be done without configuration files.
Skip using the ViewRenderer plugin. Without the ViewRenderer, you need to manually configure Zend_View and add render() calls to Controllers. This is actually very simple to do and is fairly fast - fast was never really part of the ViewRenderer's genetics.
Use autoloading. Strip require_once calls from the framework library so unneeded files are ignored. Replace uses of Zend_Loader_Autoloader with a not-so-crazy autoloader function. In fact, pray Zend_Loader is never used - it does a lot of file ops that, to date, have never been explained to me as having any value.
Preload everything (Symfony 2 Preview does!). It buys you some performance cookies and equalises the speed baseline. Using a simple preload script is not that hard.
We've used ZF in a lot of high traffic sites, and we've had no issues so far. We did have to jump through a few low-hanging hoops, though.
Some suggestions:
use Zend_Queue to help with batch mailing
use Zend_Cache whenever possible
Use plugin loader cache
Strip require_once calls in favor of autoloading
Get rid of components you don't want. (as suggested, you would not need MVC stack for CLI / mail)
We chose Sphinx in favor of Zend_Search_Lucene (enormous performance gain)
The bottom line for us has been this: development time is much, much more expensive than hardware. The flexiblity and higher re-use of code completely trumps any minor performance losses we had to deal with. For the most part, the performance overhead was very fixed.
You ask:
Is it possible to achive acceptable performance using Zend Framework? Has anybody such an expirience?
Yes, I have experience with a site with millions of users. But you do need to use techniques to deal with the high load. Caching etc...
A CDN can help a lot. Look into developing with the cloud. Amazon might be a pain to get started with but it helps you scale if need be.
I guess what I'm saying is, the Framework may cost you a bit of performance, but helps make maintenance possible and building it faster (once you get over the learning curve). Then you you have to evaluate what needs to be done to improve performance (although it helps a lot to plan for what will be obvious problems, right from the get go).
I know of several companies that use ZF in high-performance/high-load scenarios. I don't know which ones I can state and which ones I can't, but some of them are media companies who have to handle popular TV shows. Others handle live sporting events. Others are multi-billion dollar companies who need to serve their internal organizations. So, ZF is being used by plenty of companies who run pretty high-load sites. One of our case studies is Fox Interactive (http://framework.zend.com/about/casestudies) and I know of several other customers who use it for high-performance websites.
Zend Framework MVC, out of the box, will be quite fast. My blog comes back in about 100ms without caching and there's a fair amount of stuff that happens on my front page. I could probably drop that down to 50ms with some internal caching (Full page caching could drop it down to single digit ms, but then it's not touching ZF).
Seconding Joe's answer. I've also seen ZF deployed on a few sites handling millions of requests and have yet to encounter a problem. When dealing with that amount of traffic it's a good idea to use other strategies beyond your framework, including but not limited to caching and the use of a CDN.
I've found most frameworks will call or create many class instances per request which I think is what causes people to say that framework X is slow without having any real world experience with it. Any hit you take there can be easily mitigated by using an accelerator and caching.
If you already have a team of devs you've hired, I'd suggest using what they feel most comfortable with and have the most experience with. Best case they'll be able to tune their code for that framework.
A lot of the framework, any framework really, is used for building and managing the project development but the resulting project is 'just' php, html, css etc. the same as any other php web site. So what evidence do you have, that's real timing against other framework and non-framework built sites not anecdotal evidence, that a Zend project site is slow.
Edit -- answers to below --
I don't think the structure that the framework uses will hurt performance. It may be more a question of PHP being acceptable and then how much 'overhead' is added with the site design and the optimisation of loading say JavaScript's etc. I would imagine that using the Yui guidelines of minifying JavaScript and CSS and loading them in the correct order and making sure the PHP code is efficient will help. You can also use other standard things such as DB Caching and Zend Accelerator will speed things up. One thing to be careful of would be the DB connection. The use of an ORM layer might have an impact.
However back to the original question about the framework i think it is similar to asking if using Eclipse or Textmate has an effect on the speed of the resulting site.
I'd like to create some small websites using PHP as the programming language. I've looked at several frameworks but they all appear to be rather large and am not sure how well they will run in a shared hosting environment. I was wondering if anyone knew of frameworks that work well in shared hosting? I'm looking for something with MVC and ORM features and anything else extra would just be a bonus.
ElisLabs codeigniter(http://codeigniter.com/) should fit the bill like a glove.
This is my framework of choice when i do php projects.
Although I personally love CakePHP, and I've done many projects for clients running on shared hosts and it runs just fine, if a light footprint is really important for you, CodeIgniter would be my choice.
CakePHP. I don't see why it wouldn't work in shared hosting.
As has already been mentioned, CodeIgniter is a great PHP framework. It has a great user guide, community and a light footprint.
Notch up another vote for CodeIgniter - it's really easy and quick to learn, and is very lightweight, so good on shared hosting.
Since you are talking about small applications, it probably doesn't matter. CodeIgniter seems to be the fastest.
However for big applications (or ones that could become big (talking about load, not quantity of code)) I suggest not using a "general" frameworks at all. They may speed up development a lot, but in most cases they are real computer power killers.
According to - for example - some tests of Paul M. Jones frameworks eat up about 90% to 97% of the system ressources (CodeIgniter scored good by eating just 85%). That means that if your computer can handle 100 requests per second using a framework you'll have only 15 possible requests left before the server goes boom.
Of course the results will vary based on the application. The tests Paul performed were simple "Hello World" pages with no database and no other calculations. Obviously the "application / framework" ratio will change a lot if you add application logic.
Not trying to stop you from using a framework... Just trying to make you think before you start coding...
Kohana is a good choice too. Originally forked from CodeIgniter, it's now been rewritten as a PHP5-only, real open-source project that is optimized for speed, rapid development and flexibility.
Side note/disclosure, I was originally involved in the fork that formed into Kohana. CodeIgniter (at least about a year or two ago, when I was involved) is very not open to user contributions. I had several enhancements and bug fixes that I contributed patches for, that ended up rotting, basically, as they were ignored*. As a result, several people took up a huge interest in getting their contributions in, and while Kohana is based on all the same principles and ideas as CodeIgniter, the implementation is much better, and much easier to work with.
(*: not due to code quality, just do to simply not being interested because it didn't necessarily fit in the direct that Ellislabs was going since it was the backing for their commercial product. It was like if a change was made -- even if it made a huge improvement to the library -- that would have required them to rewrite/change anything they had built on top, it would be ignored.)
I really like CakePHP, it is simple and has pretty good documentation. I have set it up pretty easily on MediaTemple, I just had to change the webroot variable in the config file.
Qcodo is another option to review.
Take a look at Sonic. It's built to be really light and fast. The core framework is less than 3000 lines of code, and you can create an entire app with just a single 26kb file.
It has an extension framework set up to allow you to install extensions on top of it (ORM, Database, Cache, etc).
view site:
http://sonicframework.com
browse source:
http://github.com/ccampbell/sonic
I am thinking of using a PHP framework called CodeIgniter.
One of the things I am interested in is its speed. I have, however, no way to find out how fast it is, and would rather not simply take the word of their website for it. Does anybody know how I can determine its speed myself, or can someone tell me of a site that can?
Code Igniter also has some built-in benchmarking tools:
http://codeigniter.com/user_guide/general/profiling.html
Yes, the problem is you have to build your application to profile it.
At work we had a couple of projects written outside which we load-tested before putting them on our main boxes. We were quite surprised to find critical performance problems with both; one was written in CakePHP and the other was written using Drupal. I don't think this highlights a problem with any framework or CMS other than the need to do profiling and load-testing on any site which is going to get significant traffic. In both cases it was what the developer had done, rather than the characteristics of the software platform, that caused the problem. For example, there was a recursive function call the developer had created in the Cake project which instantiated the entire Cake object every recursion and this would have taken out the server had it gone live under load.
In my opinion performance should not be a deciding factor in choosing a framework; the objective differences are likely to be marginal and the way you use it is likely to cause far more performance problems than the inherent performance of the framework.
I believe that to scale any PHP application to run under load, you will need an opcode cache and you'll need to write in intelligent content caching using something like memcached or whatever built-in caching your framework supports.
If your site is database-driven I would be very surprised if your bottleneck would be the application framework. "Fast" as in faster development is what I would worry about rather than "fast" as in speedy handling of requests. Significant optimization is better done by caching strategies and optimizing your database access.
Besides database access your own code will be where most of the time for each request is spent (and even that is usually not significant compared to database access), the framework will likely not be affecting the time spent on a request, unless it is really badly written.
It way be better to look for a framework which has good caching support (which Code Igniter may have, I don't know), that will almost always save you more time than the few milliseconds you could shave off the request handling by using a slightly faster framework.
Have a look at the Zend Framework too, it has the benefit of being PHP 5, whereas Code Igniter is still PHP 4, as I understand it. That may be an issue when it comes to speed, but in favor of which framework I don't know. Zend has good caching support and a database profiler that can help you find where your bottlenecks are.
i'd recommend testing it for yourself. use xdebug's profiler to create a cachegrind compatible file and webgrind to visualize the file.
that way you end up with very reliable information.
CodeIgniter is plenty fast for most projects. Some have posted here and if you Google, you will find that it compares favorably to other frameworks with respect to speed.
I would agree with another poster that performance is usually not a big concern when it comes to framework choice. The major frameworks all have sufficient performance for most projects.
I maintain a site that gets slammed a few times a year. Last year the development team rewrote the entire site using Codeigniter and we have had much luck in terms of performance. Additionally, the time it took to perform the rewrite was minimal as this framework is quite easy to work with. CakePHP in my opinion is also a good choice if you find that you don't like Codeigniter.
For CodeIgniter and other PHP frameworks, PHP Quick Profiler is very handy for benchmarking and measuring speed especially for database queries. You must check this out:
php-quick-profiler
It's very easy to install and provides an awesome GUI for examine different benchmarking tests.