Living at the Edge? Optimizing availability in IoT

Cloud, edge, and fog computing enable Internet of Things (IoT) applications, offering high connectivity, scalability, and high availability. Smart cities, smart agriculture, and e-health systems are examples of IoT applications that can exploit the opportunities generated by these technologies. However, due to the scale and complexity of the IoT and the heterogeneity of the devices and service level expectations, resource management is not a trivial task. While facilitating storage and processing

at the end device (the edge), at the intermediary layer (the fog), or centrally (the cloud), new points of failure are introduced at and between each layer. In some use cases, such as e-health, device availability also has high criticality. Any downtime impacting one or more components in the architecture can result in adverse effects and/or additional logistical effort and cost. This chapter discusses extant research on how cloud, fog, and edge computing is being used in smart city, smart agriculture, and e-health systems.
Keywords Availability • Smart city • Smart agriculture • e-health • Internet of Things • Edge computing • Cloud computing • Fog computing

IntroductIon
For large-scale Internet of Things use cases, such as smart cities, cloud computing offers a flexible and on-demand infrastructure to execute realtime analytics applications and context-specific information systems. In addition, it also provides support for data retrieval and visualization, which can provide relevant information for city managers to create new public policies and consequently improve the city operations (Kakderi et al. 2019). While cloud computing can mitigate some of the limitations of IoT devices, the location of cloud data centres can introduce issues for delay-sensitive applications. Usually, cloud infrastructures are located far away from the edge devices resulting in a high delay for both transmitting large volumes of data and providing a response (Tang et al. 2015). To solve this problem, fog computing is a technology that acts between the edge devices and cloud computing. Fog computing extends the cloud capabilities providing cloud features closer to the edge devices using low cost devices but with computational capabilities needed to support local data analysis (He et al. 2017;Santos et al. 2018). Despite the advantages that cloud-to-thing (C2T) integration technologies bring to IoT applications, its adoption also brings challenges. In such scenarios, the system relies on different operational layers to offer a variety of applications to the end-user, increasing the complexity of resource management . Moreover, while improving the availability of the service as a whole, C2T solutions present more points of possible failure, for example in the IoT sensors, fog devices, and data centre subsystems. In several scenarios, system availability is critical due to strict requirements, such as real-time data health monitoring, for example patient vital data, and real-time decision making, for example rerouting due a transit accident.
This chapter discusses extant research on how cloud, fog, and edge computing is being used in smart city, smart agriculture, and the Internet of Medical Things.

Smart cItIeS
By 2030, more than 60% of the world's population will live in an urban environment (Gaur et al. 2015). This urban growth places significant strains on the city infrastructure. New solutions are required to mitigate emerging problems from rapid urbanization and an aging population such as energy consumption, safety, public services, sustainable development amongst others (Arroub et al. 2016). The use of information technologies is a solution to create smart urban environments to both reduce the impact of population growth and improve overall quality of life (Chakrabarty and Engels 2016). A smart city is an urban space composed of several complex systems, covering infrastructures, technologies, social and political structures, and the economy (Gaur et al. 2015). To control and monitor this environment, a vast array of heterogeneous devices, such as street cameras for security systems and sensors for utility and transportation systems are placed across the city, which generate a huge amount of data (Arasteh et al. 2016). Such data can be used to identify possible bottlenecks and also to provide insights for city managers thereby supporting better decision making. It unsurprising therefore that the market for smart city solutions is forecast to grow to US$237.6 billion by 2025, expanding at a CAGR of 18.9% from 2019 to 2025 (Grand View Research 2019).
Notwithstanding the opportunities inherent in smart cities, they also bring several challenges. A smart city is a mixture of multiple systems with distinct, sometimes conflicting objectives. These systems may make use of their own (devices) end-points or share municipal devices to collect data over time, many of which have no significant computational capability to store and process this data. These simple devices act as the city's sensing layer located at the edge of the network.
An example of smart city infrastructure for traffic monitoring that integrates edge, fog and cloud computing is illustrated in Fig. 5.1. The cars and roadside units generate data about the number of cars driving on the streets, street conditions, and unexpected events, such as accidents. This information can be used to adjust the traffic lights in order to relive potential traffic congestions in and around the location of the incident. This information can be processed locally by the traffic lights (fog nodes) to reduce the delay. However, the cars and the city infrastructure could process incidents, for example car crashes, and send alerts to change the route for vehicles and give priority to city or emergency services to arrive at the scene of the incident (Ali and Ghazal 2017).
Integrating edge, fog, and cloud infrastructure to implement smart city services introduces high management complexity. Multiple devices and applications must work together to keep the services and data available for the applications. Generally, device failure or data loss can have a significant impact on critical systems and in smart cities, these problems can cause  (Baldoni et al. 2015). The infrastructure and massive volumes of data generated by smart cities, often requiring real-time analysis require robust and efficient resource planning and, consequently, better resource utilization (Bawany and Shamsi 2015).
The importance of the availability of data and services of smart cities have been addressed by some authors considering different smart city scenarios. For instance, smart parking solutions using IoT and cloud technologies are being proposed to help drivers and as a consequence decrease the carbon footprint. However, such solutions rely on specialized infrastructures (sensors) and real-time data availability. Mugarza et al. (2019) address the need for high availability in smart city power management systems. They describe a solution for dynamic software updates for power system management. This type of system cannot be interrupted as any system outage or malfunction may result in a blackout in some or all of the city. The solution presented enables building power management software to be updated without restarting, thus ensuring that the system will be fully functioning.
The vehicular cloud, sometimes referred to as V2C, offers vehicular communication technologies and infrastructures for smart vehicles to communicate with other parties, among themselves and with the cloud (Soyturk et al. 2016). Smart-Vehicle-as-a-Service (SVaaS) acts as intermediary layer between the vehicular nodes (e.g. smart cars or municipal vehicles) and the service providers (e.g. municipal authorities or commercial services) so that relevant services such as transport management, ondemand transportation services, and media services, can be provided (Aloqaily et al. 2017). Smart vehicles is a good example of heterogeneity in end devices as smart cars may use a wide range of technologies, be used by multiple drivers, and have different levels of criticality depending on their use or importance as perceived by service or infrastructure providers. Aloqaily et al. (2017) present a system for discovering and selecting vehicular services based on QoE requirements and vehicle clusters that are geographically proximate and have similar service profiles.
As discussed, the provision of services and the availability of resources is a great challenge in smart city due to different demands, user requirements, and services specifications. For delay-sensitive applications, fog computing is a key technology since it provides cloud-like functionality close to the end-user thereby reducing the latency and increasing the application availability (Tang et al. 2015). In a smart city scenario, where a huge amount of data is generated, the fog nodes can act as a backup in case of a cloud failure, increasing the availability of the system as a whole (Stantchev et al. 2015). Finally, different redundancy mechanisms can be used between the fog applications and the cloud data centres. The edge nodes may provide more essential services in a distributed way, and in case of failures, other edge nodes can keep the service available.

Smart agrIculture
Agriculture plays an important role in the world because as a source of livelihood and as its role in the global food supply chain. According to the WHO, an estimated 820 million people did not have enough to eat in 2018. The situation is most alarming in Africa, as the region has the highest rate of hunger in the world. In Eastern Africa, for instance, about 30.8% of the population is undernourished. Promoting the optimization of the food supply chain can help eradicate hunger and poverty in the world (Bu and Wang 2019) but also contribute significant to economic development (Gondchawar and Kawitkar 2016).
In recent years, digital monitoring and control are being used in agriculture systems to improve the food supply chain from farm to fork. Precision agriculture involves the measurement and optimization of granular field operations. Currently, sensors can offer highly accurate measurements of crop status, and based on those values, actuators are able to manage, for instance, irrigation, change climate factors, or enrich the soil with the needed nutrients (Mulla 2013). This, in turn, can result in improved harvest forecasting, collection, planning, and downstream operations (McKinsey 2016).
Again, smart agriculture bring challenges as well as opportunity. Smart agriculture is characterize by high volumes of heterogeneous sensors and actuators distributed across wide areas, often with intermittent connectivity. Figure 5.2 presents a smart agriculture use case with integrated IoT, fog, and cloud to increase process automation and efficiency. Heterogeneous sensors collect relevant crop data such as humidity, temperature, pH metering, and soil conditions; and heterogeneous actuators, such as water sprinklers, ventilation devices, lighting, automated windows (in glasshouses), and soil and water nutrition pumps react according to the data.
To overcome some of the coverage and connectivity issues inherent in agriculture, Zamora-Izquierdo et al. (2019) propose that at the crop layer (farm), IoT sensors and actuators are deployed and connected to fog devices. This connection can be made by the intermediary layer (represented by a microcontroller and/or a drone). These devices (e.g. Arduinos, ESP32, drones, etc.) have limited hardware capabilities to process and store the data from sensors, but have connectivity to forward data for superior layers. Fog devices are located geographically close to the IoT sensors and microcontrollers and can provide computational resources to process or storage data locally. Delay-sensitive applications can use fog devices to obtain fasters responses. Finally, cloud computing provides "unlimited" computational resources to process and store the data collected by sensors. Thus, further analysis that may demand more powerful resources, such as big data analysis and machine learning model training, may be executed on cloud environments. However, as cloud infrastructure is located far away from microcontrollers and fog devices, there may be a Researchers have proposed a wide range of architectural solutions for smart agriculture. TongKe (2013) uses sensors to send information (such as water quality, monitoring of animal, and plant growth) directly to cloud data centres. This information is processed to provide relevant outputs for system users. Bawany and Shamsi (2015) propose a similar architecture where the information is sent for cloud and can be visualized using a smartphone app. As these architectures depend on the cloud for processing and storage data, a basic requirement is an Internet connection; this can be a constraint in remote places. Therefore, for smart agriculture scenarios, the usage of fog devices to process data locally can increase the availability of smart agriculture systems. In large scenarios, with a huge number of sensors and actuators, the combination of fog and cloud can be used to increase the coverage area of the system and improve the service and data availability. A precision farming system using IoT and cloud infrastructure is presented by Ibrahim et al. (2018) using a horticulture use case, and specifically ornamental flowers. System inactivity can cause severe damage to crops, since ornamental flowers are very sensitive to humidity and temperature changes resulting in financial damage to the farmers. The proposed system is composed of a large number of sensors, controllers, and actuators, and a 1-in-2 fault-tolerant management system to mitigate the likelihood and impact of failures. By using the fault-tolerant approach, the system availability increased from 99.45% to 99.997%.
In smart agriculture, downtime can be very costly (Ibrahim et al. 2018). For instance, if a temperature change is perceived but action is delayed or no action is taken, it can cause significant financial losses because the entire crop can be compromised. Downtimes can occur due to different reasons, such as sensor and actuator failure. In these cases, minimizing the system downtime becomes critical. Ibrahim et al. (2018) suggest developing countries encounter high repair times as spare components are not usually stored on site and farmers may have to import them, and replacement costs are rarely predictable. Again linking, system failure and downstream replacement logistics could result in better mean time to repair metrics and mitigate financial losses.

the Internet of medIcal thIngS
The promise of information technologies for health care has been a continuous theme in discourse by policymakers, academia, and industry. It is widely accepted that in the institution-centric health care system that dominates most developed economies, patients and health care professionals are separated from each other by time and space (Tachakra et al. 2003;Topol 2015). Time, place and people drive not only costs but inconvenience in to health care systems suffering under the increasing pressure of aging populations and chronic diseases (Topol 2015;Deloitte 2018). Gatouillat et al. (2018) defined the Internet of Medical Things (IOMT) as the interconnection of medical-grade devices with broader health care infrastructures, connecting personal medical devices with each other and with health care providers whether hospitals, medical researchers, or private companies. The advantages of such a vision of e-health ubiquity and interconnectivity are multifold. As well as unburdening the health system, IoMT technologies can contribute to increased efficiency, reduced costs, risk mitigation, improved quality of care and quality of life, and increased transparency in the health system (Darkins et al. 2008;Ossebaard et al. 2013;Farahani et al. 2018). Despite these advantages, the IoMT is not without challenges, not least structural and technical ones. For example, the pervasiveness and criticality of e-health technologies, the impact of adverse outcomes, and sensitivity of personal health information requires IoMT systems to have higher levels of reliability, safety, and security than typical systems (Gatouillat et al. 2018).
For the most part, the IoMT is configured along the C2T continuum comprising three layers (Fig. 5.3): (1) cloud computing and big data infrastructure, (2) Internet-connected gateways, and (3) a (body) sensor or sensor networks (Rahmani et al. 2018). Advances in sensor design, cloud computing, and wireless communication technologies has made it possible to develop more affordable medical systems. In the last two decades, there has been a rapid advance in the sophistication of sensors including intelligent sensors, in vivo sensors, and sensors that can increasingly mimic the biological senses. The availability of low cost relatively sophisticated sensors for monitoring patient life plays a significant role in the evolution of the IoMT and vice-versa (Chiuchisan et al. 2014). A reliable system in the IoMT must achieve its functional goals at all times to avoid patient safety issues, adverse outcomes, or additional effort and costs by patients or health care providers (Gatouillat et al. 2018). At the same time, budgetary constraints remain. The system architect therefore has a trade-off to resolve between system availability and cost. Araujo et al. (2014) propose stochastic models, Stochastic Petri Nets (SPN), and Reliability Block Diagrams (RBD), to represent an e-health service relying on mobile cloud computing infrastructure, that is cloud infrastructure, wireless communications, and a mobile device. Availability analysis were conducted considering scenarios with different wireless communication channels (Wi-Fi and 4G), different battery discharge rates, and different timeout values. Results suggested that the timeout for 3 Smart e-health scenario integrating IoT sensors and wearable devices, microcontrollers, fog devices, and cloud computing delivering a message is the metric that had a greater impact on mHealth system availability, and that Wi-Fi and 4G communication channels presented similar impact.
Vargheese and Viniotis (2014) focus on usage of sensors to provide vital data as soon as the patient is discharged from the hospital, and they state that the availability of the cloud and IoT devices is a critical aspect in this scenario. However, not only do the devices (at software and hardware levels) play an important role regarding availability aspect; the role of the network connection also needs to be highlighted. Considering that communication link is not always available, the Delay Tolerant Networking (DTN) approach can be exploited, storing the data locally and conducting updates as soon as a network connection becomes available (Sawand et al. 2014).
The availability of e-health systems is critical to ensure the sensing and integrity of vital information collected from the patient. According to (Yang 2014), "because resources, time, and money are always limited in real world applications, we have to find solutions to optimally use these valuable resources under various constraints." This is particularly true in the context of an e-health monitoring system. Historically, one of the barriers to the widespread adoption of telemedicine was cost factors associated with heterogeneous devices and single point solutions (often for therapeutic application) (Gatouillat et al. 2018). da Silva  propose an e-health system architecture based on sensors, fog, and cloud computing. Stochastics models were proposed to evaluate how failures of the infrastructure impact the availability of the e-health system. The authors evaluated four different scenarios with different configurations. The experiments showed that the e-health system availability increases from 99.7299% to 99.9709% when the application present in the fog and in the cloud are complementary and has redundancy. In addition, sensitivity analysis results shown that the fog and cloud applications are the components that have higher impact on the e-health system application.

concluSIon
The Internet of Things is huge opportunity for both business and society. However, as we rely more and more on the Internet of Things, we require more availability and uptime, particularly where the criticality of the use case is high. This chapter discussed some of the challenges and solutions to address availability in smart cities, smart agriculture and the Internet of Medical Things.
Improving the availability of a system is not an easy task, especially if availability, including connectivity and coverage, are not considered in the conception phase. Some techniques, such as redundancy and geographic distribution, are commonly applied but at same time, from a management perspective, they bring many challenges.
When adopting resource redundancy and distribution, the service provider has to deal with both implementation and maintenance costs. Ibrahim et al. (2018) andda Silva Lisboa et al. (2018) demonstrate the availability gain of having a fault-tolerant approach with redundancy but they do not provide the cost analysis. Both physical and applications layers should be taken into account when analysing the costs of the system implementation and maintenance. The physical devices, connected through a network, host a set of software that most of the time is running on virtual machines (VMs). Orchestrating all these (physical and virtual) components is complex and demand specialist personnel or automated systems.
If the system is designed to scale (up and down), better resource utilization can be achieved and the system will be able to handle different workloads with different requirements. As a result, downtime due to poor scaling capacity will be reduced. Virtualization is a technique that supports service scalability by allowing the deployment of new service instances on demand. Similarly, machine learning approaches are being used to predict workloads and propose better resource planning (Liu et al. 2017;Le Duc et al. 2019). However, there is no way to avoid failures. When it happens, automatic failover approaches should be in place to minimize the system unavailability and reduce mean time to repair.