Energy users can deploy an energy storage system (ESS) to reduce the energy cost by charging the energy when it is cheap and using the stored energy when it is expensive. A grid operator can deploy ESS to reduce the peak load by storing the energy when the demand is low and releasing the stored energy when the demand is high. Achieving these two objectives, at the same time, is challenging due to their contradictive relationships. Thus, most approaches put constraints on the amount of energy that can be drawn from the grid to guarantee the peak load is below a threshold. In this paper, we propose a novel approach that clusters energy users into a set of groups and operates independent ESS in each group for minimizing the energy cost of each group. The results show that when the users in each group have similar energy consumption pattern and the battery capacities arc optimally allocated to each user groups, the energy cost and the peak load of the grid can be reduced at the same time due to asynchronous charging and discharging pattern of the ESS among the clustered users.