Recently we got the chance to look into the load speed issue for one of the project, we are required to improve API performance for a listing screen. The project was built in AngularJS and API being created in Laravel.
Two of the major listing pages of the application has become hell slow with time, 10 seconds to be exact. The application itself is quite big and is going under heavy development for last 2 years. As it’s a SAAS based so data is growing rapidly. In this article, we are going to present the steps we took to improve API performance and how we managed to reduce the Load time of the Laravel API for listing screens which were taking more than 8 sec to just a sec.
This is one of the most common mistakes, especially with those teams which don’t have a special database administrator assigned in the project to manage and create the database, and the task of creating the migration is left for the developer. While creating the migrations for the database, or schema in general, developers tend to ignore creating indexes and they generally get away with it for quite long, Until your application is live and data grows to a point where you start feeling the performance issues, those long spinning loaders drops a hint. Continue reading
Here is the list of some of the useful Laravel Eloquent Tips and Tricks which are usually ignored by developers and not used as much as these should be.
1.) Expressive where syntax
$products = Product::where('category' , 3);
you can do this instead
$product = Product::whereCategory(3);
just append column name in plural case after where
2.) Date filtering
I recently got to work a site which was more like a directory. One of main trick there was to show random advertiser on the site so that each advertiser get’s some chance for displaying on sites front page. That was actually easy until this has to go with pagination. Back then I didn’t even knew if there’s any way to achieve mysql pagination with random ordering.
Problem is, you show some random advertisers on 1st page but on second page you must see another set of random advertisers (excluding what you already seen on 1st page) and so on. you see where’s it’s going?
Mysql Rand(seed) function to rescue
SELECT * FROM your_table ORDER BY RAND(351) LIMIT 10, 10;
“Hello World!”. That Looks familiar isn’t it? We mad guys “The Coders” used to start learning every new thing with this. So Here I am getting a chance again to write “hello world”.
Hi Guys, I am Ankit, a Web Developer and Team Leader. I am starting out this blog hoping to learn from you guys so be right there.. A lot of interesting stuff to follow I guess.