A Serverless Advanced Metering Infrastructure Based on Fog-Edge Computing for a Smart Grid: A Comparison Study for Energy Sector in Iraq

The development of the smart grid (SG) has the potential to bring significant improvements to the energy generation, transmission, and distribution sectors. Hence, adequate handling of fluctuating energy demands is required. This can only be achieved by implementing the concept of transactive energy. Transactive energy aims to optimize energy production, transmission, and distribution combined with next-generation hardware and software, making it a challenge for implementation at a national level, and to ensure the effective collaboration of energy exchange between consumers and producers, a serverless architecture based on functionality can make significant contributions to the smart grids advanced metering infrastructure (SG-AMI). In this paper, a scalable serverless SG-AMI architecture is proposed based on fog-edge computing, virtualization consideration, and Function as a service (FaaS) as a services model to increase the operational flexibility, increase the system performance, and reduce the total cost of ownership. The design was benchmarked against the Iraqi Ministry of Electricity (MOELC) proposed designs for the smart grid, and it was evaluated based on the MOELC traditional computing-design, and a related cloud computing-based design. The results show that our proposed design offers an improvement of 20% to 65% performance on network traffic load, latency, and time to respond, with a reduction of 50% to 67% on the total cost of ownership, lower power and cooling consumption compared to the SG design proposed by MOELC. From this paper, it can be observed that a robust roadmap for SG-AMI architecture can effectively contribute towards increasing the scalability and interoperability, automation, and standardization of the energy sector.


Introduction
In the past few years, the use of technologies associated with distributed energy management and renewable energy has increased considerably. In this account, the smart grid (SG) is found to be a prominent solution to improve the efficiency and transparency of energy transfer between producers and consumers. This new approach follows the principles of transactive energy (TE), a systematic process of controlling and managing energy flow while maintaining a dynamic balance across electrical systems to market-based standards and economic values [1]. TE can solve the energy supply and demand problems between consumers and producers by smartly optimizing energy flow and directing This paper aims to propose a scalable serverless architecture design for the SG-AMI, with Iraq as a case study. The study suggests much more dependence on the FaaS and BaaS services model on top of virtualization technology to reduce the total cost of ownership and improve operational performance. The rest of this paper is structured as follows. Section 2 elaborates on the technologies relevant to the SG architecture. Section 3 specifies the case study for SG-AMI deployment by Iraqi MOELC, while Section 4 explains the proposed SG-AMI architecture that considers Fog-Edge computing and virtualization to improve the scalability, system performance, total cost of ownership, and operational flexibility. Section 5 presents a scenario with improved system configuration to evaluate the performance and response management that shows the proposed architecture improves the latency and response time compared to the architecture used by MOELC. Finally, Section 6 concludes the paper.

Related Works
Due to the increased demands to improve energy consumption, the economy has shifted towards developing intelligent networks to optimize energy utilization [18]. The use of intelligent energy networks can optimize energy flow, the way it is produced, transmitted, and distributed, while reducing the cost of energy. To support such networks, different computing infrastructure can be used to solve the implementation hurdles related to the ineffective use of multiple smart devices and huge data handling. The four computing technologies are traditional, cloud, fog, and edge computing. First, the most basic traditional computing (TC) which by far is the least preferred method despite being simpler to implement compared to other computing methods. On top of limitations such as low performance and scalability, TC follows a centralized computing architecture that can limit the smart grid's potential, thus increasing the TCO.
Second, the revolutionary cloud-based architecture which is widely used to cater to high demand responses in a large-scale network deployment [19]. Cloud computing (CC) is the backbone of smart services and products as it performs the communication process and provides network access to Energies 2020, 13, 5460 4 of 22 many SG computing resources while responding in a real-time manner to run multiple applications. The realization of the concept via the smart grid is based on handling a vast amount of data, and this data management is achieved by using big data technologies [20]. It has the potential to optimize the supply of resources to consumers while retaining a low investment and cost of operation. According to [21], CC can effectively increase the efficiency, flexibility, security, and scalability. Although CC supports high performance based on centralized computational platforms, it still has restrictions such as traffic complexities, high latency and response time, security, and privacy issues [22,23].
Third, fog computing (FC) is an additional layer between the smart grid physical network and the cloud that fills the processing power gap between these two entities. The problem of massive traffic generation by CC can be resolved using fog computing [24]. Data that do not necessarily need to be sent to the cloud is processed in the fog layer devices, thus reducing the response time [14]. Several studies [25,26] have proposed that the latency and time to response issue can be resolved using fog computing that provides most of the computational resources within the end user's proximity. However, these studies lack an analysis of expected cost-effectiveness for the proposed architecture compared to other conventional infrastructure. FC can reduce processing costs by refining the data and providing local processing support to smart grids [27]. This aspect can reduce the risk of latency affecting the overall performance, while increasing the amount of data processed by smart grids and decreasing the use of extra resources, ultimately reducing the overall cost.
Finally, edge computing (EC) that enables advanced systems to perform complex computations, processing delay-sensitive and bandwidth-hungry applications near the data or end-user devices. It extends CC capabilities, bringing services close to the network's edge [14][15][16][17][18][19][20][21][22][23][24][25][26][27][28]. Like FC, EC complements CC by significantly reducing the latency, improving the virtualization support, allowing seamless connectivity, reducing energy consumption, and improving energy management. [29] to improve the overall total cost of ownership. Although FC effectively manages local customer's requests while providing network and computation services between users and cloud computing applications, edge computing can observe smart grid subscribers' distribution and consumption patterns. However, note that if enough computational power is not supplied to edge computing, latency can be slower than fog computing [14]. Moreover, edge computing is limited to performing computing activities at the network's edge. Compared to cloud computing, edge computing handles load distribution and agility, which can play an effective role, specifically by monitoring the smart grid's electricity distribution.
Smart computing, from CC to EC, is also beneficial to promote optimal utilization and reduce construction and operating costs while increasing scalability and flexibility. In an energy sector, the smart computing infrastructure is compatible and can be paired with virtualization technology to improve performance by flexibly creating and distributing virtual resources [30]. Implementation and relation of new components and testing applications concerning smart grids can be conducted virtually to avoid expensive and risky operations. Previous works from Chen, Liu, and Ha [31] and Worighi et al. [32] suggested that SG virtualization enhances the utilization of resources and simplifies data center management. The studies further proclaim that because real power grids cannot be used for validation and testing, virtualization in smart grids can provide accurate testing results similar to the real systems. India and China have been undergoing a significant transformation in adopting information technology in smart grids despite challenges such as establishment and transformation cost. To counter these issues, India has opted for virtualization technology to manage its hardware and data related to smart grids [33]. Smart grid virtualization provides a dynamic pricing model in real-time and energy management to reduce load at peak times. Thus, the issue of establishing a secure and reliable communication network that has the potential to support multiple applications in AMI and Distribution Automation (DA) can be resolved using virtualization technology integrated on smart grids [34]. A further summary of previous works on SG computing infrastructure and virtualization technology is organized in Table 1. This study is distinguished from its previous counterpart by being a comprehensive study proposing a serverless SG-AMI architecture with edge and fog computing to overcome both sides' challenges in the cloud computing-based solution. Moreover, it introduces virtualization technology to increase system performance and flexibility, to elastically offer many types of services models such as FaaS, BaaS, and SaaS to form a more adaptable business logic design while reducing the total cost of ownership.

Case Study on Iraqi Energy Distribution Sector
In this section, two design proposals that were obtained for the SG-AMI based on the Iraq energy distribution context are presented. The proposed SG-AMI architecture designs was produced by the Iraqi Ministry of Electricity (MOELC). Information was gathered through multiple meetings, workshops, and field visits across different departments of the Iraqi MOELC departments, including the Planning Department, Operation, and Control Department. The proposed SG-AMI designs by the MOELC show the current nationwide networks with serial structure design where the ministry HQ (zone-1) connects to four major distribution government companies (zone-2), which are in Baghdad, Middle, South, and North of Iraq. Each main distribution company dominates a group of smaller branches or sub-regions (zone-3), representing the different Iraqi provinces in this zone that are geographically closer to a zone-2 area. All distribution companies in zone-2 are linked to the ministry HQ (zone-1) using optical fiber composite overhead ground wire (OPGW) and microwave (MW) links as backup links in case of emergency or natural disaster situations. However, most sub-regions in zone-3 are either not connected or use poor WAN links to reach zone-2. Currently, the statistics of the MOELC proclaims that more than 95% of subscribers in zone 3 are using mechanical meters. However, in the design, sub-regions in zone-3 are assumed to be linked to the smart meters (SMs), and all SM are assumed to be connected using older generation GPRS cellular network or PLC (power line communication).
Consequently, both designs are based on the idea of dealing with the portions of SG in the distribution sector, i.e., AMI components such as Head End System (HES) and Meter Data Management System (MDMS). The solution proposed for distribution infrastructure should ensure cost reduction in construction, operation, and maintenance. Figures 3 and 4 illustrate the architecture of the two MOELC proposals, as found in [35], which will be the baseline document for comparison and validation with our proposed design.
3.1. MOELC Proposal 1: HES-Only in Zone 3 Figure 3 shows the SG-AMI architecture in Proposal 1 of the Iraqi MOELC. It shows the plans to distribute HES in all sub-regions (zone-3), with direct links to main regions using OPGW and/or MW links. These communication infrastructures are dedicated to the MOELC and are used to connect all sub and main regions to ensure high availability. This aspect further lowers the cost of data transmission while ensuring high security and stability. However, it will increase the cost of construction. MDMS will only be used on the four main regions in zone-2, and these will directly link to the main MDMS system in HQ (zone-1). MDMS in HQ is responsible for handling data processes in all zones based on traditional computing, while all other sub-regions (zone-3) are prospected to send all gathering data to be processed by MDMS in zone-2. The main advantage of this design is ensuring the independence of both hardware and software such that the data of each region are independent of each other, and each branch is not affected by any interruptions faced by other regions operating across Iraq.
However, this design's disadvantages include high latency, low scalability, and high maintenance and operation cost. Most importantly, this design is intended to be used by MOELC government-linked companies (GLCs) without considering the expected transformation of distribution to smaller private companies. The design does not foresee the integration of these infrastructure resources with other companies in the private sector. This will force private sector companies that would like to work in the distribution sector to build their own complete set of SG-AMI Infrastructure, to be integrated into MOELC SG-AMI. This will increase the total cost of ownership (TCO) and waste of national resources.   Figure 4 shows the SG architecture in Proposal 2 of the Iraqi MOELC. There are minor differences in the second proposal that reduce the total cost of ownership (TCO), according to the specialists in the MOELC. They proposed to modify the first design by installing both HES and MDMS at main regions (zone-2) while connecting the sub-region using public WAN links. This design will significantly reduce the TCO as well as maintenance and operation costs. However, the design will lose its independence and revert to centralization control, significantly increasing the latency. Besides, adopting public network communication links (WAN) for data transfer between zones and regions will greatly raise security concerns. Therefore, MOELC needs to include some advanced security technologies to enhance Energies 2020, 13, 5460 9 of 22 cybersecurity, such as intrusion prevention systems (IPS), advanced encryption technologies, and deep packet inspection. Like Proposal 1 of MOELC, this proposal design is also unscalable and does not consider the expected transformation of the private sector. Table 2 summarizes the differences between the above MOELC designs Proposal 1 and 2. From the technical specification document by MOELC [35], it is clear that specialists in MOELC have depended on the legacy stack (Traditional Stack Computing) to develop the proposed designs. It was noted that the proposal by MOELC overlooked technologies such as fog computing and virtualization, which have been known to provide high efficiency, high scalability, increased reliability, and ease of future expansion.

Proposed Design
In this section, a design that considers the Iraqi MOELC future expansion, especially on transforming the private sector, is presented. The design suggests a serverless infrastructure for SG-AMI that offers services as a function (FaaS) using a virtual grid. In this design, MOELC acts as a service provider to both public and private companies in the distribution sector to use this infrastructure and offers all SG-AMI services as function without requiring the public and private companies to build their infrastructure. This will help many companies invest in energy sectors with a minimal total cost of ownership and use pay-as-you-growth models based on their respective needs and business plan perspectives. The proposed design combines the fog and edge computing for SG-AMI (FC-EC SG) architecture. It consists of three zones, where each zone has a scalable four-tier architecture based on virtualization technology and is divided into many regions and application groups or functions. The zone-3 functions to receive the collected data from any devices or smart objects in the grids for processing and forward the request or data for the feature process in zone-2 through API getaway. In zone 2, all active processes for specific data manipulation will be performed. The data in zone-2 are also classified as hot data (most frequently accessed data) or cold data (infrequent or low accessed data) based on historical transactions and feature extraction. Only hot data will be stored in zone-2, while all cold data will be forwarded to zone-1 to be stored and called back only when needed. This process will ensure less data traffic to be saved and reduce the time to respond in zone 2. Figure 5 shows a high-level overview of our FC-EC SG-AMI proposed architecture design across regions, while Figure 6 shows the detailed proposed FC-EC SG-AMI by zone to illustrate the components in each region and to highlight the FaaS services block. Meanwhile, Table 3 shows the suggested distribution of different types of applications and services across SG-AMI zones and the role of services, which include 9 FaaS, 4 SaaS, and 2 BaaS roles. Further elaboration on the design can be found below.  Table 3. The distribution of SG-AMI services according to zones and the role of services.

Applications or Services
Zone-3 Zone-2 Zone-1 Role of Services

MDMS system Function as a Service (FaaS) Billing Systems
Software as a service (SaaS) Dynamic data center management  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. The proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing and virtualization technology. Each energy company in the distribution sector (public or private) will have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). The description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing virtualization technology. Each energy company in the distribution sector (public or private) have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. The proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing and virtualization technology. Each energy company in the distribution sector (public or private) will have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). The description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing virtualization technology. Each energy company in the distribution sector (public or private) have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing virtualization technology. Each energy company in the distribution sector (public or private) have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. The proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing and virtualization technology. Each energy company in the distribution sector (public or private) will have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). The description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. The proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing and virtualization technology. Each energy company in the distribution sector (public or private) will have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). The description for each component of the design is provided as follows.  Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. The proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing and virtualization technology. Each energy company in the distribution sector (public or private) will have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). The description for each component of the design is provided as follows.   Figure 6). description for each component of the design is provided as follows. Each region in a zone is equipped with 4-tiers (Web, Application, Data, and Analytics. The proposed design enhanced the 3-zones design by MOELC by using Fog-Edge computing and virtualization technology. Each energy company in the distribution sector (public or private) will have its private block of service or function as service (FaaS) containing the 4 tiers ( Figure 6). The description for each component of the design is provided as follows.

Web Tier/Presentation Tier
The web tier handles communication between a web server and web browser with request reception through API [36]. The main advantage of this tier is its capability of handling all traffic while generating responses for incoming requests. In the proposed design, the web tier will respond to any API query made by the subscribers or SMs regarding network transactions. These requests will then be forwarded to the application tier.

Application Tier
The application tier is responsible for solving critical problems while achieving productivity advantages using resource sharing via specific application components based on business logic [37]. These components can help to enforce data rules, business algorithms, and regulations defined by the government to ensure that data structures are consistent within multiple or specific databases. Any request made by the user in the decentralized system of the proposed design will be resolved here. The application tier will perform actions based on the request of the users. If the request involves the transaction between a consumer and a producer, the application tier will execute actions.

Data Tier (Database and Storage)
The data-tier interacts with data stored in permanent storage or different database schemes in shared resources [37]. It also controls the stored data (hot or cold data type), manages the database system, and makes sure that data is independent of processing logic or application servers while enhancing overall performance and scalability. The data-tier in the proposed design will consist of information regarding the subscribers' transaction and energy consumption. This energy consumption data will be hosted in a secured and distributed environment privately, while subscribers will have the authority to share or manage their own personal data only.

Analytics Tier
The analytics tier is responsible for providing operational flexibility in the generation and distribution of the energy sector by mapping the value of data with analytics information such as power consumption forecasting [38]. Other functions include monitoring, troubleshooting, security analysis, long-term storage, and frequent ad-hoc analysis. In the proposed design, consumers' energy usage, related transactions, and contribution to the smart grid system will be monitored. Based on this information, the analytics tier will execute troubleshooting if any issue arises.
A few enhanced features like network and security subnets are included in the overall proposed design as seen in Figure 5. A network subnet is the division of a network into two or more networks to increase routing efficiency, improve network security, and enhance network management control [39]. For this purpose, high-speed data center switches, routers, and load balancers are used while using optical fiber links between servers and switches that have 10 Gbps and 25 Gbps network speeds. Moreover, next-generation firewalls with a recommended set of security requirements will be developed by security subnet in all communication interdependencies in the smart grid. These next-generation firewalls can prevent DDoS attacks by detecting it before its occurrence, using OpenFlow firewall algorithms [40]. This aspect disconnects the SG server from the network. However, in case of a strong DDoS attack, the security subnet will ensure that DDoS attacks cannot block all bandwidth, CPU power, and processing time of the smart grid (SG) servers by using a source tracking method. In the context of the present research, this method will detect the source of any attack made towards the proposed design and will be eliminated before it could harm the smart grid ecosystem. Table 4 shows a summary of the technical comparison between the different computing technologies using the proposed design.

API Gateway
API gateway is an essential tool for controlling and monitoring connected devices [41]. It provides easy transport for input/output data to SG-AMI systems from different regions, a more straightforward web-based configuration via any browser or any other type of application in a unified form, multiple communication protocols support and can connect machines to the virtual power plant and PLCs. The API gateway allows efficient communication between multiple devices in a network [42]. It can control, analyze, and monitor devices' requests while connecting heterogeneous smart meters devices. Besides, API gateway is a single-entry point for a selected block of services or microservices. It has access to support private cloud-based microservices for business processes such as user management, authentication, collaborative features, and much more [43]. Thus, this API gateway can act as a security door for a smart grid that would allow requests from authorized users and SMs to interact with it asynchronously and securely by sharing their private token with the desired application.

External Backup Storage and Backup and Redundancy
External backup storages are a basic safety precaution method that comes into play as soon as there is a system failure in the SG-AMI system to safeguard all crucial data in emergencies, such as natural disasters. It is an effective way of ensuring that the data related to customers subscribers and energy data such as generation, transmission, and distribution are saved in secure external storage away from the main infrastructure [44]. Furthermore, redundancy backup features are activated in an active-active mode or active-passive mode to ensure that the grid performance is not affected by external or internal faults and keeping the grid in a perfect working state [45]. The use of external storage and redundancy backup methods in the proposed SG-AMI can increase the system's reliability while reducing the risk of data loss in case of an emergency.

Performance Evaluation
To evaluate the performance of our proposed design across each computing scenario, i.e., CC-SG, FC-EC-SG, and TC-SG, a virtual laboratory environment was built using Microsoft Azure for both CC-SG and FC-EC-SG models. Three tiers architecture was used in Azure to achieve the design requirement (web, service plan application, and database servers) to represent our proposed design's one service block ( Figure 6). The Azure and local environment's network components were optimized and reconfigured for each experiment to meet each scenario requirement. An improved system configuration and multi controls for data processing purposes have been deployed in a laboratory environment to read consumers' energy consumption, analyze the data, and evaluate proposed designs' performance. A sample of 200 households with smart meters installed was taken at a rate of energy consumption of around 6000 W, representing a standard household use of electronic devices such as cooling systems, washing machine, TV, electric cooker, lighting, etc. The capacity of 15 power transmission stations (20,000 W), where Home Area Network (HAN) was considered as an area Energies 2020, 13, 5460 14 of 22 network with 1 Gbps and 10 Gbps capacity. In the grouped routers of our experiments, the following performance metrics were measured: • Throughput: The number of data requests directed per second, measured in Kbps • Latency: The average packet delay variation between the packet request and response, measured in milliseconds • Time to response: The time is taken between data transmission and system response, measured in milliseconds.
The data traffic and data throughput for 200 houses were assumed to be on average of 5 devices per house (i.e., a total of 1000 devices). It was set for ten days, and two reading values were taken daily. Table 5 shows the lab configuration setting for each model, while Figure 7 shows our improved system interface used for reading and responding to lab test performance measurements.   Figure 8 shows the network traffic in CC-SG, FC-EC-SG, and TC-SG scenarios, while Figure 9 shows the average packet delay variation. Laboratory experiments have shown that when the demand for data traffic increases, FC-EC SG-AMI appears to be more efficient in reducing data rates that needed contact with the main services because it provides the required data to the consumer rather than forwarding the request to multi-services points in more than one location. This allows the reduction of network loads and data traffic in a general smart grid network. All approaches taken show a higher latency level or average packet delay variation as the volume of data sent increases over time. The proposed approach received a relatively low percentage compared to the rest of the approaches, where Network traffic load (kb) show 20-45% of improvement, while latency (ms) achieved around   The response time compared to the increase in demand is also an important factor in determining the efficiency of any proposed design, where we examined the response time with a steady increase in the number of requests systematically, and the proposed approach gives the least response time as shown in Figure 10. The proposed FC-EC SG-AMI architecture can also be evaluated by several metrics such as system availability, the total cost of ownership, power, and cooling consideration. The system availability, A system was derived as a ratio of Mean Time Between Failure (MTBF) and its Mean Time to Repair (MTTR). MTTR indicates the time required for repairing a system and bring it back to the normal state, while Mean Time between Failure (MTBF) is the predicted failure time during the operation of a system [46].
where T maintainance is the total maintenance time, T operational is the total operational time, N repairs is the total number of repairs, N f ailures is the total number of failures and λ is the mean number of failures per million hours. In ideal or standard situations, A system is expected to be close to 100% or 0.999% [47]. For ease of comparison, one Tier (e.g., Application Tier) in one region (e.g., region A) in a zone was considered for analysis, given by application group A (G A ). Six function servers (X) are assumed in the G A , where these servers' effectiveness was measured. Table 6 shows the MOELC physical ad FC-EC-SG virtual server specifications used in our assumption. As discussed at the beginning of the current section, the MOELC design is based on physical servers with a serial structure, while our design is based on virtual servers with a parallel structure. This means that six physical servers are needed for the MOELC design, while our proposed design will only need two to three servers to achieve the GA's requirements. Two cases are considered in more detailed for the proposed FC-EC-SG virtual server configuration:

•
Case 1: Six Function Servers (X) in each application group, where each Server (S) can operate 2 functions • Case 2: Six Function Servers (X) in each application group, where each Server (S) can operate 3 functions.  Table 7 summarizes the server configurations for the MOELC physical server and Case 1 of FC-EC-SG virtual server designs. Table 7. Comparison between virtual and physical server configuration for the G A.

MOELC Physical Server Configuration FC-EC-SG Virtual Server Configuration (Case 1)
In the server's serial structure, a failure of one server will affect other servers in the structure. Assuming a single server availability of 99.9%, and n is the number of serial devices or servers, the system availability is given by However, with our proposed parallel server structure, the system availability remains in perfect condition, i.e., A system, parallel = 99.9% for ideal or standard situations. Considering the total of 525,600 min in a year, this translates to downtime of only 52.6 min/year for virtual in comparison to 315.36 min/year for physical platforms. This indicates that our proposed design offers a better performance in system availability. Each physical server costs around USD7000, with a power requirement of 271 W and a cooling requirement of 1200 BTU. Table 8 summarizes the performance of MOELC proposed architecture and our proposed design. Server wise, the total cost of ownership, uninterruptible power supply (UPS), and cooling requirements for physical configuration is 50-67% higher than our proposed virtualized configuration. Moreover, the system capacity can be calculated based on the number of served requests (in request per second), in our case, the number of SMs or the number of subscribers' requests that are served in the block of services. This will mainly be based on server hardware specifications and available resources such as CPU type and the number of the processor core, RAM capacity, and storage disk read and write speeds. Moreover, the amount of data sent per request, and the number of requests should be per day, and an hourly basis for each object such as SM will also affect the overall system capacity. This information is dynamic as it depends on the smart meter usage specifications and the amount of mobile data need per transaction. Therefore, it must be calculated for each company independently to determine the required resources available for each block of service. Table 9 shows the estimated need for each server's required resources to serve 25,000 standard three-phase smart meters [48]. The expected advantages of Serverless SG-AMI proposed design in smart grid architecture are summarized as follows: • Reduced Operation Cost: Serverless SG-AMI offer a unified structure that will reduce the total costs of ownership required to build an independent infrastructure for each company operating in this field. Instead, these companies will pay as grow by using MOELC function as a service (FaaS) model.

•
Elasticity Through Independent Environment: Serverless SG-AMI design offers the separation of physical hardware and software and function layer from that of the virtual layer, enabling users to run non-compliant or, in some cases, obsolete operating systems on newer or alternate hardware. These technologies allow system upgrades and non-disruptive testing, where different software versions can run in parallel with physical hardware. Moreover, virtualization provides flexibility in server allocation, hence allowing users to choose the virtual server to execute a physical server application. On the other hand, the use of hardware-based servers in the proposed design would somehow reduce the flexibility because each server would require manual installation of an operating system. It would restrict the proposed design from running a non-compliant operating system. • Performance Tuning: Serverless SG-AMI design significantly improves system software performance by running multiple platforms across a distributed architecture. Moreover, cross-platform systems can also be monitored, altered, or changed towards certain needs, reducing the risk of performance degradation. The performance of data centers of the SG-AMI can be optimized using the proposed architecture, as it contributes to abnormal delay variations that affect overall system efficiency.

•
Simplified Resources Management: The proposed architecture provides efficient handling and monitoring of different types of SMs and many computing and networking resources. It makes resource management easier because the virtual servers have flexible resource expansion capability. SG-AMI possess the potential to increase computing resources' efficiency by applying dynamic resource calling, micro-service sharing, and FaaS model.

•
Flexible Scalability: With SG-AMI, several components such as smart meters, sensors, network servers, and other resources can be operated, tested, and scaled up when needed. This reduces the hardware deployment cost need for system testing. Besides that, it utilizes FaaS services and allows communication with external applications through API Gateway. This is incredibly useful in the proposed design as it offers flexible upscaling depending on the future needs as the system grows. In other words, it assures that no excess cost is being wasted.

•
Marketing Adaptation: The proposed SG-AMI can also handle the changes associated with future consumer demands, energy profile of consumers, and environmental concerns by offering support to potential services and artificial intelligence (AI) analytic applications through a flexible FaaS model. The combination of blockchain and AI techniques can observe and identify consumers' energy patterns and enable a value-added and tailored provision of energy products.

Conclusions
The paper proposed a comprehensive Serverless Fog-Edge Computing for SG-AMI architecture to improve the SG design provided by Iraqi MOELC. A Serverless Fog-Edge Computing with integrated virtualization technology-based architecture promises several benefits: reduced traffic complexities, improved scalability, and reduced TCO. This combination provides an efficient computing architecture while maintaining the data processing in the distributed network and decentralized services. The proposed architecture was also compared with traditional computing as proposed by MOELC and the pure cloud computing architecture, using different metrics such as network traffic load, latency, and time to respond. It was observed that the proposed FC-EC-SG reduces the total cost of ownership, power, and cooling consumptions while increasing the overall performance. However, Serverless architecture has some limitations that need more attention from researchers such as data security and privacy, dynamic business logic design, cost-effectiveness in long-running processes, and testing and debugging of new functionality. Furthermore, with its flexibility, the design is adaptable to blockchain services, which have gained increasing attention in modern technology to enable transparent transactive energy. Decentralizing the smart grid with blockchain service would require the system node's approval for any blockchain structure changes. This might create more advantages but also security vulnerabilities if it is largely adopted in the energy sector with our current design. We are looking at this perspective for our next research work.