We had an big application written in PHP+js+mysql. some of our bosses, decided (making a big mistake since they are no developers) to give this application in outsourcing for rewritting it from a developer company. They rewritte the application with Zend Framework+ Doctrine, giving us back a very veru very slow application, if in the old application on module to load taked 1 second now it takes 4 seconds.
Till now we have done the impossible to fast up this up: activated cache server, migrate application to linux, caching everything possible but it is still very slow very slow.
I need from all developers experience how to optimize and make faster this application written with zend framework and doctrin2 (we cannot remove doctrine, and we have alreedy implemented the cache system)? tips tricks, ideas any anwser will be welcome.
Same as with any PHP application:
Enable Xdebug on your development machine and do some profiling to see where the bottlenecks are
Enable the MySQL slow query log to see if the queries can be improved
you can also look at the DB profiling features in Zend_Db to see if the app is doing unnecessary queries or loading more data than it needs.
For all website application use this firebug's pluggins for optimize your code, you can really win in performance !
Yahoo Yslow pluggin
Google PageSpeed pluggin
with there, you have a notation for your page, with listing for improve your fastest's application.
After, for Doctrine2 , you can use fetchArray() for few little request, (global, users use fetchAll() ) .
FetchArray is more faster than fetchAll for request, just because fetchArray return just an Array, and fetchAll return all object linked in your request... ( many time, array is sufficient).
Hope I help You.
Related
I'm about to start an iOS project that requires pulling user's data from an SQL Database and viewing it within the App. Before I begin I'm looking for conformation that I'm taking the right (best) route.
My Plan:
App starts on login page (app will display data from another service)
App uses AFNetworking to post request to web service
Web service gets user data from SQL Database and sends back JSON
App uses JSONKit to parse the feed and load into Core-Data
App uses info from core-data to populate UI
Does this seem like an appropriate way to get the info into Core-Data from SQL? Any suggestions for doing things differently?
Thanks.
Are you receiving the response from the web server in JSON? If so, the fact that the server is using an SQL database is immaterial. What you need to know is how to parse JSON for inclusion in a core data store. Cocoa is my Girlfriend has a pretty good tutorial up.
Part 1
Part 2
To answer your comment, here's what I've done.
Display a login screen. The login credentials should be stored in the keychain for security. I've used SSKeychain for this.
To handle sending and receiving data from a web request your best option is to use a pre-built library. I've always used ASIHTTPRequest, but since it is no longer under active development, you should probably look around a bit before you commit to anything. I'm sure there are nicer and cleaner libraries out there.
You need to parse the JSON responses. I'm a fan of JSONKit. It's very fast, very easy to use, very robust.
Pulling data out of the core data store and displaying it in the interface will be no problem for you. If you create a new project in Xcode most of the setup will be done for you.
Now, there are a lot of projects out there that attempt to combine web requests, json parsing and core data loading into one framework. I've tried to use a few of these and haven't had much luck. The ones I've tried haven't been robust and very difficult to debug. Setting up your own request/parse/load code is not difficult at all, just a bit time consuming.
I am sure that there are a lot os ways to make implement this problem. Your solution is one of the popular solutions I guess but you could connect to the DB via a socket and talk with the database directly e.g. Going over a port 80 web site has the advantage that the possibility of some kind of firewall blocking the communication is very low. I would solve this kind of problem the same way I guess.
I've recently released an ZF app to production environment, and I'm getting some troubles because this app is running in three different instances behind a load balancer.
These three app instances are sharing the same lucene indexes through NFS. I've just realized NFS is discouraged by Zend Framework documentation.
How should I deploy my app?
Well, the easiest solution to this, if you're using the index ONLY to search, would be to copy the index and give each app its own copy to query.
If your app IS editing the index then you have a harder problem to solve. You'll more than likely have to choose a different search/index method besides Zend Lucene. You could use the Java Lucene instead, although I don't know if there's a PHP API for it.
I'm at a loss at what else you could do. I hope someone comes up with a crafty solution to this. Sounds like an interesting problem.
I want the way with the fastest execution time. I'm not feeling comfortable of using web service because i need to create separate php pages and retrieve data as xml. If you think its good to use web service please tell me why. I want to code my database queries right on my c/objective c pages.
I've been searching for libraries. I saw this sequel pro - won't i have any problems on using this - like licensing issues? I also saw this libmysqlclient of cocoa but some say its not working well. I've also read about a library developed by Karl Kraft found here http://www.karlkraft.com/index.php/2010/06/02/mysql-and-objective-c/ but don't know if i could trust this.
I would really appreciate you help.
Definitely build a web service to act as an abstraction layer to your database. Here are some significant reasons in my opinion:
Since you want speed, you will be able to add caching when using the webservice, so you will essentially eliminate the need for identical queries to run (sometimes).
If you need to change your data model later, you just have to modify the webservice backend and don't have to update your app.
You can better control security by not exposing the database to the world, and keep it safe behind the web service.
Your database credentials should not be stored in an app. What if you needed to change those?
I strongly suggest a web service. Hope this helps.
Connect to your DB by PHP and output the result as JSON
is much better and faster then xml and less coding if use JSON Framework.
and never never try to connect to your DB from your iphone because it easy to sniff out the request from iphone.
Being safe then Sorry, keep that in mind
I Use Zend Framework 1.11 and this is really slow for me.
I Have a button and then, when I click on it, that perform an ajax request.
The response is Small. I Return a
Hello World
The response time is 125ms.
To much for this small ajax request.
Anybody have an idea.
Thanks.
well , it shouldn't take that much , could you please post the code and your os information ,
but i suggest to
run xdebug profiler
http://devzone.zend.com/article/2899
http://www.slideshare.net/samkeen/profiling-php-with-xdebug-webgrind
Are you using anything from:
Locale
Currency
Db
Also try using optcode cache (like zend accelerator). ZF can be slow on PCs with low IO performance while it loads many small files.
We have 125ms response on server for our ecommerce with hardcore optimalization (but without cache).
I've prototyped an iPhone app that uses (internally) SQLite as its data base. The intent was to ultimately have it communicate with a server via PHP, which would use MySQL as the back-end database.
I just discovered Google App Engine, however, but know very little about it. I think it'd be nice to use the Python interface to write to the data store - but I know very little about GQL's capability. I've basically written all the working database code using MySQL, testing internally on the iPhone with SQLite. Will GQL offer the same functionality that SQL can? I read on the site that it doesn't support join queries. Also is it truly relational?
Basically I guess my question is can an app that typically uses SQL backend work just as well with Google's App Engine, with GQL?
I hope that's clear... any guidance is great.
True, Google App Engine is a very cool product, but the datastore is a different beast than a regular mySQL database. That's not to say that what you need can't be done with the GAE datastore; however it may take some reworking on your end.
The most prominent different that you notice right off the start is that GAE uses an object-relational mapping for its data storage scheme. Essentially object graphs are persisted in the database, maintaining there attributes and relationships to other objects. In many cases ORM (object relational mappings) map fairly well on top of a relational database (this is how Hibernate works). The mapping is not perfect though and you will find that you need to make alterations to persist your data. Also, GAE has some unique contraints that complicate things a bit. One contraint that bothers me a lot is not being able to query for attribute paths: e.g. "select ... where dog.owner.name = 'bob' ". It is these rules that force you to read and understand how GAE data store works before you jump in.
I think GAE could work well in your situation. It just may take some time to understand ORM persistence in general, and GAE datastore in specifics.
GQL offers almost no functionality at all; it's only used for SELECT queries, and it only exists to make writing SELECT queries easier for SQL programmers. Behind the scenes, it converts your queries to db.Query objects.
The App Engine datastore isn't a relational database at all. You can do some stuff that looks relational, but my advice for anyone coming from an SQL background is to avoid GQL at all costs to avoid the trap of thinking the datastore is anything at all like an RDBMS, and to forget everything you know about database design. Specifically, if you're normalizing anything, you'll soon wish you hadn't.
I think this article should help you.
Summary: Cloud computing and software development for handheld devices are two very hot technologies that are increasingly being combined to create hybrid solutions. With this article, learn how to connect Google App Engine, Google's cloud computing offering, with the iPhone, Apple's mobile platform. You'll also see how to use the open source library, TouchEngine, to dynamically control application data on the iPhone by connecting to the App Engine cloud and caching that data for offline use.
That's a pretty generic question :)
Short answer: yes. It's going to involve some rethinking of your data model, but yes, changes are you can support it with the GAE Datastore API.
When you create your Python models (think of these as tables), you can certainly define references to other models (so now we have a foreign key). When you select this model, you'll get back the referencing models (pretty much like a join).
It'll most likely work, but it's not a drop in replacement for a mySQL server.