Online services and applications have grown rapidly in the last decade. The network is necessary for many services and applications. Many technologies are invented to meet the requirements of online services, such as micro-services and serverless computing. However, the traditional network architecture suffers from several shortages. It is difficult for the traditional network to adapt to new demands without massive reconfiguration. In traditional IP networks, it is complex to manage and configure the network devices since skilled technicians are required. Changing the policy of a network is also time consuming because network operators need to re-configure multiple network devices and update access control lists using low level commands. The management and configuration becomes more complex and challenging, when the traffic in a network changes frequently. SDN (Software-defined networking) is an innovative approach to manage networks more flexible. It separates the control plane from forwarding devices and uses a centralized controller to manipulate all the forwarding devices. The separation offers many benefits in terms of network flexibility and management. The controller can provide a global view of a network. Using the controller, network operators can manage and configure all the network devices at a high level interface. With SDN, a network can adapt to new demands by updating the applications in the controller. However, all these benefits come with a performance penalty. Since the controller manipulates all the forwarding devices, the performance of the controller impacts the performance of the whole network. In this thesis, we investigate the performance of SDN controllers. We also implement a benchmark tool for OpenFlow controllers. It measures the response time of an OpenFlow controller and fit a phase-type distribution to the response time. Based on the distribution of the response time, we build a queueing model for multiple controllers in an OpenFlow network and determine the optimal number of controllers that can minimize the response time of the controllers. We design an algorithm that can optimize the mapping relationship among the switches and controllers. The load of controllers can be balanced with the optimized mapping relationship.