This paper focuses on the scalability of one of the most important VNFs (Virtual Network Functions) in a 5G core slice, AMF (Access and Mobility Management Function). When incoming requests exceed the capacity of a single AMF instance, they will be rejected by the AMF and lead to the failure of user equipment to attach to 5G. To solve this problem, we propose to dynamically scale the number of active AMF instances based on Management Data Analytics Function (MDAF) currently under study by 3GPP by monitoring the loading of AMF. Using Tacker and OpenStack to set up a MANO environment, we design and implement MDAF as a VNF to provide data analytics services required for the scalability of AMF. In addition, we also design a Load Balancer as a VNF between RAN (Radio Access Network) and AMFs to receive the load distribution policy from MDAF and distribute the traffic load from RAN to suitable AMFs. After thoroughly testing two systems, one equipped with MDAF-based scalability and one without, it shows that when the MDAF system encounters a large amount of UE registration requests, it can maintain a higher registration success rate than the non-MDAF system. Moreover, the MDAF system can not only reduce the processing time for individual UEs, but also ensure a stable CPU state of AMF instances.