skip to Main Content

I have developed a Laravel application where I submit an array with base64 data as a payload. In the backend, I don’t interact with the request directly; I simply return a response. However, I’ve noticed a significant delay when submitting the form in the production environment, and this delay seems to be correlated with the length of the array. Surprisingly, when I submit the same payload in my local development environment, I receive an instant response. Is there a way to configure the server to achieve the same level of responsiveness as in the local environment?

Local Environment
Local Environment

Production Environment
Production Environment

I tried to do a live migration of Hypervisor in Digital Ocean to improve the performance, but the issue still persisted.

2

Answers


  1. You are uploading 5 files. Your server and response has to wait for the upload to finish. This will depend on the size of the files and the connection speed.

    In localhost the file is just being copied, which is much faster.

    What you can do is implement some ajax chunk upload that can upload the files just as you select them and show some progress bar, before you pres the submit button.

    Login or Signup to reply.
  2. Many problems may occur depending on the size/type of data in relation with the parameters below.

    Please provide more info:

    • http method
    • Are you sending the payload as file (multipart) or post body?
    • What is the size of the data uploaded?

    Run phpinfo() in both environments and post the results for the following parameters

    ; Maximum amount of time each script may spend parsing request data. It's a good
    ; idea to limit this time on productions servers in order to eliminate unexpectedly
    ; long running scripts.
    ; Note: This directive is hardcoded to -1 for the CLI SAPI
    ; Default Value: -1 (Unlimited)
    ; Development Value: 60 (60 seconds)
    ; Production Value: 60 (60 seconds)
    ; http://php.net/max-input-time
    max_input_time = 60
    
    ; Maximum execution time of each script, in seconds
    ; http://php.net/max-execution-time
    ; Note: This directive is hardcoded to 0 for the CLI SAPI
    max_execution_time = 30
    
    ; Maximum amount of memory a script may consume
    ; http://php.net/memory-limit
    memory_limit = 128M
    
    ; Maximum size of POST data that PHP will accept.
    ; Its value may be 0 to disable the limit. It is ignored if POST data reading
    ; is disabled through enable_post_data_reading.
    ; http://php.net/post-max-size
    post_max_size = 8M
    ; Maximum allowed size for uploaded files.
    ; http://php.net/upload-max-filesize
    upload_max_filesize = 32M
    
    ; Maximum number of files that can be uploaded via a single request
    max_file_uploads = 20
    

    Also as already noted by kris localhost is literally the same machine so data upload is near instant, since all of network lag is omitted.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search