This study proposes a real-time abnormal heartbeat detection and emergency system for helping users to obtain immediate rescue and treatment in a short period of time when they suffer from severe heart disease, for example, acute myocardial infarction (MI) or fatal malignant arrhythmia. The proposed system can detect abnormal heartbeat waveforms and automatically send out emergency signals. The detection of abnormal heartbeat waveforms is based on the cross-correlation analysis between the normal heartbeat sample and each of the input heartbeats. The normal heartbeat can be manually selected by the user or automatically selected by the program. An abnormal heartbeat is detected if the cross-correlation coefficient is less than 60%. The abnormal heartbeats from the MIT-BIH malignant ventricular arrhythmia database and MIT-BIH arrhythmia database were enrolled to test the performance of the proposed system. If an abnormal heartbeat is detected, the system will automatically make a phone call and send out a message to the emergency contact person. This message contains the address and GPS coordinates of the user's current position so as to shorten the rescue time. The proposed system also records the original heartbeat waveforms before and after abnormal heartbeats are detected for future medical reference. Moreover, the user's walking path with GPS coordinates and real-time heartbeat waveforms can be monitored by the cloud system to provide more rescue information.