A market will be allocatively efficient if it is producing the right goods for the right people at the right price. An allocatively efficient market is therefore one which has no imperfections.
The demand curve is equal to the marginal utility curve i.e. the (private) benefit of the additional unit, while the supply curve is equal to the marginal cost curve i.e. the (private) cost of the additional unit. In a perfect market, there are no externalities, meaning that the demand curve is also equal to the social benefit of the additional unit, while the supply curve is equal to the social cost of the additional unit. Therefore, the market equilibrium, where demand meets supply, is also where marginal social benefit meets marginal social costs. At this point, net social benefit is maximized, meaning this is the allocatively efficient outcome.
However, it is possible to have Pareto efficiency without allocative efficiency. By shifting resources in the economy, a gain in benefit to one individual could be greater than the loss in benefit to another individual (see Kaldor-Hicks efficiency). Therefore, before such a shift, the market is not allocatively efficient, but might be Pareto efficient.
When a market fails to achieve allocative efficiency and resources are not allocated efficiently, there is said to be market failure. Market failure may occur with imperfect knowledge, differentiated goods, resource immobility, concentrated market power, insufficient production, externalities, or inequality of consumers' and producers' bargaining powers.