Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KrzysztofBoksa's avatar

Loading and processing times of requests

Hello, I'm new to Laravel and I ended up with headscratching.

I have a page, with Blaze template, using foreach, to generate 2D Datamatrix codes. Those are generated with "use jucksearm\barcode\Datamatrix;" library.

I generate 20 x 2 images. One image is .php using that lib on XAMPP server. Second ones is generated through Laravel / routing:

Route::get('datamatrix/{code}', action: function (string $code ='') { return response( DataMatrix::png($code,null, 80) , 200) -> header('Content-Type','image/png'); });

Problem is that those that are generated by XAMPP are beeing processed in parallel, and total time takes around 100mS.

Those made by routing and Laravel, looks like are processed one by one, with average time 100-200ms per code so total is like 2.5-3 sec.

How can that be solved?

0 likes
3 replies
raihanrazon's avatar

If you are making one request(through Laravel route) for generating one png from one code then for 20 request it will take 20x time.

You can try to send 20 codes in the same request (array/JSON/CSV) and generate all the images in the controller action function.

You can also try JS Async approach to achieve parallel processing.

Snapey's avatar

If you load the image in the browser, then your browser will use multiple threads to load all the page assets in parallel.

A blade template is processed by a single thread, So will make the external calls one after the other.

Easiest solution is to pass the urls in the blade output and let the browser fetch them.

If you want to load them at your server then you could use Laravel's Http client which can execute queries in parallel

Snapey's avatar

also, make sure you are not using php artisan serve, which is single threaded

Please or to participate in this conversation.