Current paradigms such as the Internet of Things (IoT) and cyber-physical systems are transforming production environments, where related processes are not only faster and with higher standards, but also more flexible and adaptable to changes in the environment. To address the ever-increasing flexibility requirements while keeping current production standards, a new set of technologies is needed. This paper presents an IoT machine learning and orchestration framework, applied to detection of failures of surface mount devices during production. The paper shows how to build a scalable and flexible system for real-time, online machine learning. Furthermore, the approach is evaluated by using a novel and realistic simulation of a production line for electronic devices as a case study. The system evaluation is done in a holistic manner by analyzing various aspects involving the software architecture, computational scalability, model accuracy, production performance, among others.