1

I am using AWS EC2 services with Elastic load balancer. When I try to upload multiple images using plupload, it return error:

The specified file temporary://p1ccn4f5o41dmh1qvmefo1ohv1dq15.tmp could not be copied, because no file by that name exists. Please check that you supplied the correct filename. The website encountered an unexpected error. Please try again later.

I am using 2 EC2 server parallel for my Drupal site and on load AWS create new 2 EC2 instance. so when site is run in full load there are 4 EC2 server is running.

This issues is only comes when 2 or more Ec2 instance are running and tmp folder is working fine with single EC2 server.

How to configure tmp for multiple instance website?

Info from comment by OP:
I am using ELB with strike $_SESSION to maintained the user connection with specific EC2 instance.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
user8550844
  • 301
  • 2
  • 8
  • Please [edit] your question to add information. If you hide it in comments it might be lost. Especially if they are comments on non-answers, which have a high probability of being deleted sooner or later. – Yunnosch Jun 19 '18 at 06:08

1 Answers1

1

I have researched the multiple doc over AWS services and found that we need to maintained the user connection with specific EC2 instance.

A Classic Load Balancer routes each request independently to the registered instance with the smallest load. However, you can use the sticky session feature (also known as session affinity), which enables the load balancer to bind a user's session to a specific instance. This ensures that all requests from the user during the session are sent to the same instance.

Manage Sessions between user request and EC2 instance, we need to Configure Sticky Sessions.

The key to managing sticky sessions is to determine how long your load balancer should consistently route the user's request to the same instance. If your application has its own session cookie, then you can configure Elastic Load Balancing so that the session cookie follows the duration specified by the application's session cookie. If your application does not have its own session cookie, then you can configure Elastic Load Balancing to create a session cookie by specifying your own stickiness duration.

Elastic Load Balancing creates a cookie, named AWSELB, that is used to map the session to the instance.

Use the following create-lb-cookie-stickiness-policy command to create a load balancer-generated cookie stickiness policy with a cookie expiration period of 60 seconds:

aws elb create-lb-cookie-stickiness-policy --load-balancer-name my-loadbalancer --policy-name my-duration-cookie-policy --cookie-expiration-period 60

Use the following set-load-balancer-policies-of-listener command to enable session stickiness for the specified load balancer:

aws elb set-load-balancer-policies-of-listener --load-balancer-name my-loadbalancer --load-balancer-port 443 --policy-names my-duration-cookie-policy

Note

The set-load-balancer-policies-of-listener command replaces the current set of policies associated with the specified load balancer port. Every time you use this command, specify the --policy-names option to list all policies to enable.

(Optional) Use the following describe-load-balancers command to verify that the policy is enabled:

aws elb describe-load-balancers --load-balancer-name my-loadbalancer

The response includes the following information, which shows that the policy is enabled for the listener on the specified port:

{
    "LoadBalancerDescriptions": [
        {
            ...
            "ListenerDescriptions": [
                {
                    "Listener": {
                        "InstancePort": 443, 
                        "SSLCertificateId": "arn:aws:iam::123456789012:server-certificate/my-server-certificate", 
                        "LoadBalancerPort": 443, 
                        "Protocol": "HTTPS", 
                        "InstanceProtocol": "HTTPS"
                    }, 
                    "PolicyNames": [
                        "my-duration-cookie-policy", 
                        "ELBSecurityPolicy-2016-08"
                    ]
                },
                ...
            ],            
            ...
            "Policies": {
                "LBCookieStickinessPolicies": [
                 {
                        "PolicyName": "my-duration-cookie-policy", 
                        "CookieExpirationPeriod": 60
                    }

                ], 
                "AppCookieStickinessPolicies": [], 
                "OtherPolicies": [
                    "ELBSecurityPolicy-2016-08"
                ]
            },
            ...
        }
    ]
}
user8550844
  • 301
  • 2
  • 8