Emerging telecommunications technologies require robust frameworks for efficient network slicing. We propose a network-slicing model that aims to optimize the deployment of virtual networks on a physical network topology. Our model ensures compliance with 5G requirements, incorporating latency and capacity constraints on virtual links. Selecting slices with cost and resource requirements on the computing nodes is optimized using a Knapsack problem with revenue maximization. We propose a path protection algorithm to deal with link failures by constructing a 2-edge-connected subgraph (or two link-disjoint Steiner trees) for each slice to provide both primary and backup paths. Simulation results include comparison with existing solutions by metrics such as latency, revenue, resource utilization, number of protected slices, and computation time, providing valuable insights for network planners operating in diverse and dynamic environments. Key contributions include efficient resource allocation using the Knapsack problem, enhanced network resilience via 2-edge-connected subgraphs for path protection, and realistic simulation experiments on SNDlib dataset topologies. The simulation results show that the proposed framework improves computational efficiency compared to the recent related solutions, particularly in large network topologies where k-connected function slicing (KC- FS) subgraph embeddings take approximately 3.5 times more computation time.