A solution to the online power system security analysis is presented. For complex networks this analysis requires large computational efforts whereas computation times should be less than few minutes for the information to be useful. Even though many architectures based on conventional parallel and distributed systems have been proposed in literature, none of them is able to furnish useful results for large electrical networks. To address this problem, a distributed Web-based architecture integrating a hierarchical grid system is proposed to implement a computational engine able to execute the power system state equations for large electrical networks. The grid system adopts a resource broker to satisfy the quality of service constraints specified by the user. The resulting framework, deployed on a network of heterogeneous clusters and PCs, is used to compute the contingencies analysis of a realistic electrical grid. The experimental results demonstrate that online security analysis can be executed in few minutes even for large network complexity.