Speed issues with laravel 4 - performance

Im using laravel 4 to develop my site but im getting increaingly concerned with speed issues.
Im developing on a local machine :windows 7, apache and php 5.4
One of my pages creates an article. The view relies on a simple eloquent query to create a select field.
Using profiler the query is timed at 20ms but the page takes over 4500ms to complete. Other pages that rely on a record query, eg edit article take over 7000ms.
The pages also pull details from the authorised user
In other threads I've followed suggestions to use 127.0.0.1 as the database ip but this hasn't made a difference.
My pages uses jquery, but nothing heavy just small features.
I use the blade templating
Are my times realistic?
How can i profile to see where the bottlenecks are? Ive tried adding timers using the profiler but not had much success getting them to view.
Are there any standards i should apply?
Does blade add a big overhead?
I've not posted the code as it would take up all of the room

Related

Server side rendering or pre-rendering in Laravel and Vuejs

I have a web application in Laravel 7 and Vuejs2 which have some pages like home, about, cities and help. these page need to be crawled by search engines.
I have tried both ways, prerendering and server side rendering without success.
for pre-render there is only one package prerender-spa-plugin which is very old and not updated since 5 years.
server-side-rendering is also difficult because my web app is already designed and is going to production, it is hard to implement that now, and also not recommended to implement server-side-rendering because of 5 pages.
any suggestion are appreciated to make these 5 pages crawelable by search engine.
update:
my application contain other pages and components which do not need to be SE optimized, pages like user account and profiles.
Overall, I recommend the usage of Nuxt if you want something that could deliver a professional experience, on top of managing all the flexibility that you wish to have with an SSR/SSG tool.
Here is a more detailed answer regarding your currently available tools to achieve some SEO-crawlabale content: https://stackoverflow.com/a/69075962/8816585
You mentioned that you wished to keep some pages as SPA-only, this is also feasible thanks to the generate.exclude key of the configuration: https://stackoverflow.com/a/66472634/8816585

Symfony2 and Twig render performance issues

Just like in this topic, I have a performance issue in dev mode when adding a twig "render" tag in my app (related documentation: Embedding controllers).
Without this render tag, my pages are generated in less than 70 ms.
With the render tag, it's at least 170 ms.
And each render tag added in the app increases the page generation by 100 ms (which is A LOT : why does a normal page run in 60 ms and a render tag in 100 ms?).
I may need 4 or 5 of them on every page of my app, so that would mean at least 500 ms for each page in dev mode.
I totally understand that there is no problem in prod mode, but it's clearly not comfortable in development.
So, does somebody know any way to get rid of any useless calls, logs or code while using "render" tag in dev mode?
I have explained it just 10 hours ago. Long story short: migrate to Twig extensions.
One of my favorite features in symfony is the render tag, embedding controller calls. The profiler adds a lot overhead to every controller calls though, not only speed but uses a lot of memory. You have a few options to speed it up.
The profiler writes every data into a sqlite database by default. IIRC sqlite doesn't allow parallel inserts, so every request have to wait for their turn to access the db to flush data collectors. You can use your development db (mysql or whatever you use) to persist profiler data. A year ago I gained a lot with this in terms of speed.
You can also disable the profiler for sub requests, or only use the profiler when an exception happens. See the framework config reference for the full details.
# config_dev.yaml
framework:
profiler:
only_exceptions: false
only_master_requests: false
dsn: sqlite:%kernel.cache_dir%/profiler.db
You can move your controller logic to a service and reference it as twig global variable and then include the template rendered by the controller.
See https://stackoverflow.com/a/13245994/982075 for instructions.
The choice depends on your application. I believe that the most practical ways are:
1) Use the render tag for heavy rendered templates and use hinclude library to load them in an asynchronous way. This is very helpful when each template to be rendered is "slow" by itself (e.g. many db connections, large texts, etc.).
2) Do as proposed by m2mdas. This is a very fast solution for common cases.
I’d also follow Elnur’s suggestion with twig extensions. An alternative would be using Sonata Block Bundle: http://sonata-project.org/bundles/block/master/doc/index.html . The overhead of a subrequest with Sonata Block is about 7ms afair.

cakephp website confusing load times

I have a website that uses CakePHP 1.3.10. This CakePHP app it's pretty big, not in the amount of models or controllers (like 5 of each), but in the amount of plugins. I use the plugins as places of the website where users can access (or can't access) depending on if they have logged in already or not (well there's more reasons, but it's not important now, it's how it works). I also use a global Auth component in the app_controller.php
My issue is the following: I've noticed that the website is getting really slow when trying to access any of the pages of a plugin (when accessing the "home" page - which is not in a plugin - all is good).
The thing is that I was going to run some performance tests to figure out what's going on. I decided to create another website, exactly like the one I described, with the only difference that I removed all the plugins with the exception of one.
Amazingly (for me), when I access one of the pages of this plugin that I didn't delete, it goes super fast, like it should normally go.
So my question is: does the number of plugins really have a direct impact on the loading times of a page inside those plugins? Is there any way to "fix" this? Or is it just a coincidence and something else is going on that I missed?
Thanks so much in advance for any advise!
Reducing the amount of files and folders of my application has increased significantly the load times. I don't know what is the relation between amount of files/folders and loading speed in CakePHP, but it's a fact, at least in my website.
I've changed my cake installation to an advanced installation (as it explains in the cakephp boo) to have my files more spread out in different sub-apps, instead of having one huge app, and this has helped a lot!

C# Performance Issue

I am facing a very strange situation and don't know how to solve it...Please help me solve the issue...
I am working on a web site where a research page is created to measure the performance of tasks done in the web site. It is one type of report page which checks for different conditions into the database tables, retrieves the information and send an email to the administrator. The page runs in every hour that is 24 times per day.
Now what the issue is: The web site works correctly however when the research page runs the other pages of the web site do not work correctly. That is say for example I am on the Page1 and at the same time the research page start running. Now at this time - when research page is running - if I click on the link of Page2, the Page2 will not get displayed until research page finishes its working. Can anyone tell what could be the issue for this behavior?
Here are some more information regarding the issue:
The web site is in Visual Studio 2008 (C#) and SOL Server 2008 is
used
The SOL query is too complex for research page however, I have made
all the optimization which are possible.
There are two connection strings (with different user for same
database) used in the web site. One for the Research page and second
for all the other pages in the site
Please help me find out the issue... Thanks in advance....
This may be due to mishandling of the Thread within you website. Have you tried it by Threads and Building Asynchronous Handlers in Your Server-Side Web Code
Just check out this might help you with :
http://msdn.microsoft.com/en-us/library/ms741870.aspx
msdn.microsoft.com/en-us/library/ms741870.aspx
http://www.albahari.com/threading/part3.aspx
And also do take care of releasing the necessary resources which might be locks up the Table, even though the Thread function gets over.

Website optimization / decrease loading time in asp.net mvc 3

I have built a test website using nopCommerce open source , Everything is working fine , i need to know , why my website loading time is greater than 6 sec , the homepage works fine but the categories when clicked takes like 6-10 secs. how can i check the http request and calls to db so that i can track which function is taking a long times.
Test website is test website
Thanks
Things I would try in that order:
MvcMiniProfiler.
Analyze my code for possible performance bottlenecks using a .NET profiler.
Finally submit bugs to the nopCommerce support if the previous approaches didn't yield anything fruitful that would put my code into cause.
In between I might also checkout with my hosting provider whether he is not the cause of the slowness.
As a quick and dirty check, you can add the time it takes to generate the response as a column in the IIS logs - that will give you some idea as to whether the server is being slow to serve the pages or you need to do some front-end optimisation work.
On the front end side the first thing you need to do it merge all the CSS files for a theme into one to save on roundtrips - the browser can't render the page until it's got the CSS
All the .js files you have in the head will also block the page, can you merge them and load them later?
The performance of imagegen.ashx looks on the slow side - do you need to generate the banners on the fly or could they be pre-generated?
If the back-end side of generating the page is slow, there are some scripts around the web to show which queries are using the most CPU, making the most IO ops etc.
Below is a list of things you can improve,
1.Combine your js.
There are a few things you can use, for example, jsMin, you can read this [post] http://encosia.com/automatically-minify-and-combine-javascript-in-visual-studio/. However, jsmin doesn't seem to compress the combined js.
Another option is [jmerge] http://demo.lateralcode.com/jmerge/ It kinda does it after the fact, in the sense that you need to have the site ready to cobine them with jmerge since it only take a http link.
The best one I'v known so far is bundling and minification feature of MVC4. It's part of MVC4, however, you can get a Nuget package for you MVC 3 app.
Word of advice: bundling every js of yours is not necessarily a good idea, it even backfires someimtes, since you will end up with a big js that browser will have to download sequentially, instead of downloading several smaller ones. (you might want to look into head.js to make js download parallel) So the trick here is to keep the balance. I end up have a jquery from google CDN and bundled the rest of my js into one.
2.Put js at the bottom of the page so the browser doesnt have to load the js first before it starts to render the page. But you need to be careful with this one though, since normally you will have jquery functions doing stuff upon document.ready() at the header of the page, I adviese you moving that to the bottom of the page as well, if possible.
If you move the js reference and scirpt block in you layout page to the bottom, then you will most likely run into problem with nested js reference and js script blocks in your individual view. No worries, then you need to look into using #section (probably suitable for a discussion in an other thread) in your view and render it in your layout page, so that the referenced and script block inside your view get rendered at the bottom of the page at run time.
2.Use CDN
Pretty straight forward.
3.Combine CSS
Combine them into one, with the same tool you use for combining js, but you need to reference it at the page header, instead of the bottom.
4.Enable static content cache, something like this in your web config file
It won't help with first time load, but definitely will make it a lot faster for returning user.
5.Enable url compression
Time to first load
This is one of the metrics used by webpagetest.org. But dont bang your head against this one too much, as it basically says how fast your web server can serve the content. So probably not much you can do here form the software end.
Hope that would help!
NopCommerce is deadly slow, and the developers doesn't look in to the performance issue seriously. I have seen lot of performance related forums left unanswered. So best luck.

Resources