Purpose The advancements in the cloud computing has gained the attention of several researchers to provide on-demand network access to users with shared resources. Cloud computing is important a research direction that can provide platforms and softwares to clients using internet. However, handling huge number of tasks in cloud infrastructure is a complicated task. Thus, it needs a load balancing (LB) method for allocating tasks to virtual machines (VMs) without influencing system performance. This paper aims to develop a technique for LB in cloud using optimization algorithms. Design/methodology/approach This paper proposes a hybrid optimization technique, named elephant herding-based grey wolf optimizer (EHGWO), in the cloud computing model for LB by determining the optimal VMs for executing the reallocated tasks. The proposed EHGWO is derived by incorporating elephant herding optimization (EHO) in grey wolf optimizer (GWO) such that the tasks are allocated to the VM by eliminating the tasks from overloaded VM by maintaining the system performance. Here, the load of physical machine (PM), capacity and load of VM is computed for deciding whether the LB has to be done or not. Moreover, two pick factors, namely, task pick factor (TPF) and VM pick factor (VPF), are considered for choosing the tasks for reallocating them from overloaded VM to underloaded VM. The proposed EHGWO decides the task to be allocated in the VM based on the newly derived fitness functions. Findings The minimum load and makespan obtained in the existing methods, constraint measure based LB (CMLB), fractional dragonfly based LB algorithm (FDLA), EHO, GWO and proposed EHGWO for the maximum number of VMs is illustrated. The proposed EHGWO attained minimum makespan with value 814,264 ns and minimum load with value 0.0221, respectively. Meanwhile, the makespan values attained by existing CMLB, FDLA, EHO, GWO, are 318,6896 ns, 230,9140 ns, 1,804,851 ns and 1,073,863 ns, respectively. The minimum load values computed by existing methods, CMLB, FDLA, EHO, GWO, are 0.0587, 0.026, 0.0248 and 0.0234. On the other hand, the proposed EHGWO with minimum load value is 0.0221. Hence, the proposed EHGWO attains maximum performance as compared to the existing technique. Originality/value This paper illustrates the proposed LB algorithm using EHGWO in a cloud computing model using two pitch factors, named TPF and VPF. For initiating LB, the tasks assigned to the overloaded VM are reallocated to under loaded VMs. Here, the proposed LB algorithm adapts capacity and loads for the reallocation. Based on TPF and VPF, the tasks are reallocated from VMs using the proposed EHGWO. The proposed EHGWO is developed by integrating EHO and GWO algorithm using a new fitness function formulated by load of VM, migration cost, load of VM, capacity of VM and makespan. The proposed EHGWO is analyzed based on load and makespan.