Guzzlehttp slow performance - laravel

I am making a website using Laravel 5.4 that gets data from an api using guzzlehttp. I am making 96 requests, most of them (around 94) only return a few lines of json. This makes the website very slow to load (55 seconds). Am I doing something wrong?

Probably most of the requests can be done in parallel. Try to use Guzzle's async requests for that.

Related

Guzzle calls in helper function randomly return 'magic request methods require a URI' error

My server is running on PHP 7.2 - Laravel 5.8 - Redis Jobs - NewRelic for monitoring configuration.
The guzzle call is written inside helper function (that is autoloader from composer.json). The problem happens randomly. We get this error
production.INFO: Magic request methods require a URI and optional options array
I have read online that it's causing by a Memory leak (ref: https://discuss.newrelic.com/t/php-when-to-call-getconnection/114848)
We have many guzzle calls in our system and none is crashing and yes we do gazillions of Guzzle calls in a day.
I'm wondering if all other guzzle calls are inside a class not in a helper function. Is it OK to call Guzzle Request within a helper function, or is this the cause of this random error?
https://discuss.newrelic.com/t/php-when-to-call-getconnection/114848/14
Or restart services, that can resolve it in the short-term. I have not found any long-term fixes for this at this time.

curl php returning status code 0 for golang api

I have created a getList api in golang. Now I am trying to call the getList api from my php function using php-curl.
I am making thousands of request from my php function. However, around 15k requests are served properly but after 15k - 20k (number varies) and further requests,
Curl CURLINFO_HTTP_CODE return 0 and response is "" and curl_error return empty string.Also the curl_errno return 7
My golang getList api is simple. It takes data from db and returns it. It Does not contain anygoroutines.
I don't understand that why after 15k-20k requests it starts giving me empty response. Don't know if it is curl-php problem or golang api problem. Also It can be that my golang api is denying serving the requests.
Please help.
Have you tried to test it with HTTP testing tools like ab, httperf, jmeter or alike?
* Try to run them with different number of requests and simultaneous requests.
First put static file to the webserver and try to fetch it in the same manner. Do you see such problems? If yes, there can problems with network configuration, few buffers, sockets maxfiles and so on.
If not - try to feed this static file with golang app. If you see problems investigate them in golang settings.
If no, check your app with db config. If there are problems check DB connections. May be they're not properly closed and got exhausted.

different time in API response at first call and then call again?

I created an API in Laravel.
When I first call the API in Postman it shows 504ms, then I call it again and it shows 235ms in Postman. If I call it once again it returns about 220ms to 280ms max?
If I stop making calls to the api for few minutes (about 10-15 min) when I call it again it takes around 500ms for the first time and then it shows near 200.
Is it cached data or persistence call or Zend opCache?
Can anybody help me find out why or what is this?
Laravel supports popular caching backends like Memcached and Redis out of the box. But if you are not using their facades inside your application you shouldnt have any of this issues. Your problem is not the laravel but your server/environment configuration.

Testing Vue.js components- Laravel Testing

I am looking at testing some Vue.js components, as part of a Laravel application. So, I have a component that is used in a blade template and makes a GET request during the mounted lifecycle hook. Say this request takes 800 ms. Is it possible to use phpunit in this situation- to check the resulting HTML after said request?
I tried using sleep(1) (yes, probably a horrible idea), to give the request time to finish up (not 100% on this methodology), but the expected text was not available on the page after this brief sleep.
Here is what I am hoping to do:
$this->actingAs($user)
->visit('/teams/' . $team->slug . '/players'); // request is made when this route is hit.
$this->see('There are currently no players for this team.')
->see('There are currently no temporary players for this team.');
The see() calls resulted in error- the HTML was not present. I also checked- through the HTML output by phpunit on error, and all that is available in the HTML is what is inside of the blade template- the Vue component is not rendered at the point in which the see() call is made.
I suppose I am after some advice or direction.
I appreciate that this may not be what you're after or even compatible based on the version of Laravel you're using but have you heard about Laravel Dusk in the latest version (5.4).
https://laravel.com/docs/5.4/dusk

What is your Ext.Direct data caching strategy?

I am start using Ext.Direct alot recently, however I seem not clear how to integrate cache strategy with directFn request? eg: return 304 when data not change etc

Resources