Welcome Guest, Not a member yet? Register   Sign In
Ajax response time higher than with CI3
#1

Hello,

Recently i've worked on rewriting my web app with a lot of ajax calls to CI4. I noticed that response times are higher than when i used a CI3. Differences were not so much annoying but they were puzzling. With CI3 on my web app ajax call response times were around 70-90ms while with CI4 they were around 120-140ms. I thought that maybe there were a problem with something other like a queries to database or sth... (but it would be confusing because i rewrote 1:1 previous web app). So i made a test controller with a test view with ajax call.

Simple controller:
PHP Code:
public function test1() {
 
$array = array();
 
$object = new stdClass();
 
$object -> time time();
 
array_push$array$object );

 echo 
json_encode$array );
 } 

And a simple ajax call:
Code:
$( document ).ready( function() {
$( '#test' ).bind( 'submit', function( e ) {
e.preventDefault();

var data = {};

$.ajax( {
type: 'POST',
url: '<?php echo base_url( 'Test/test1' ); ?>',
success: function( response ) {
console.log( response );

$.each( response, function( i ) {
$( '#test_table' ).prepend( $( '<tr>' )
.append( $( '<td>' )
.append( response[i].time )
)
);
} );
},
error: function( xhr, ajaxOptions, thrownError ) {
console.log( thrownError );
}
} );
} );
} );

And i made tests. CI3 ajax call response times: 30-50ms while CI4: 60-80ms. CI4 environment were ofcourse set to production. On environment set to development they were even higher... Is there any explanation why is that?
Reply
#2

Because CI4 is doing more than CI3 did.
Reply
#3

(08-10-2021, 11:59 PM)ojmichael Wrote: Because CI4 is doing more than CI3 did.

Well, i know that CI4 is completely rebuilded but your answer is not satisfaying me... Is there any solution to decrease response times?
Reply
#4

@Yoko

What version of PHP are you running? Are the queries exactly the same between CI3 & 4?
Reply
#5

test were done on local machine or live server ?
Reply
#6

(This post was last modified: 08-13-2021, 02:35 PM by Yoko. Edit Reason: added info about browsers )

(08-13-2021, 07:25 AM)php_rocs Wrote: @Yoko

What version of PHP are you running?  Are the queries exactly the same between CI3 & 4?
PHP 7.4.2. But i did test with PHP 8 too - same results.
On my web app - yes, they were exactly the same db queries. But, as i said earlier, i even did tests with almost empty controller returning just a simple json array with one variable inside and time responses were higher too.

(08-13-2021, 09:33 AM)ikesela Wrote: test were done on local machine or live server ?
They were done on local machine (MBPr 13' late 2013)

// edit: Ah i forgot. Test were done on newest Safari 14.1.2 and newest Firefox 91.0
Reply
#7

Honestly, millisecond difference?! I'm baffled by your vision, it's a perception far beyond subtle.
I believe that software development, any software, requires goals and priorities defined at its limit, and with that version x may have changed here or there for a better overall gain, for example, in all aspects, but a difference of milliseconds for humans ...
Sorry, but that's what I think.
Reply
#8

(This post was last modified: 08-13-2021, 08:36 PM by Yoko. Edit Reason: added info )

(08-13-2021, 06:02 PM)wdeda Wrote: Honestly, millisecond difference?! I'm baffled by your vision, it's a perception far beyond subtle.
I believe that software development, any software, requires goals and priorities defined at its limit, and with that version x may have changed here or there for a better overall gain, for example, in all aspects, but a difference of milliseconds for humans ...
Sorry, but that's what I think.

My web app imitates to be a "live" app and yes - i see the difference. Mostly on more complicated db queries, when response times are much higher. In my web app there are a lot of ajax calls with long pooling or typeahead requests when answer is returning directly to the user and its visible difference. Are you telling me that i should accept it without any answers? Well im not that kind of human. CI4 is the newer framework than CI3 so i asked if its supposed to be like that. I thought that it might be even faster and im surprised that its dont. If you accept everything without any answers then its your choice - sorry, but i dont. If there wont by any solution then i will go on, so be it... but before that i will do everything as i can to check every possible solution.
Reply
#9

It's the web browsers they are cracking down on every thing for secuirty reasons.

Try turning opcache on.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

(This post was last modified: 08-14-2021, 03:35 AM by wdeda. Edit Reason: grammar correction )

No, I didn't say we should accept any answer, I said we can't compare different things, and I forgot to mention a fundamental fact: CodeIgniter is a PHP framework and the PHP server requirements for each version make them incompatible with each other , if they could run on the same version of PHP it might still be a little fairer, but it still wouldn't be fair, the development of each of the versions was based on what the available versions of PHP offered. Infrastructures are completely different and, normally, it is always necessary to keep in mind the cost/benefit ratio. Greater security and stability weigh on this relationship. Of course this goes for both, the framework and the server, PHP.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB