How do I configure a second pfSense server for failover?

I have 2 pfSense servers (the new and the old one) which are used as routers, DHCP and DNS servers. I want to configure the old one as a backup of the new one. It means that when all is ok, all the traffic is managed by the new one. And if the new goes down, I want the old managing the traffic in real time.

    Main internet               Backup internet
    (fiber)                     (ADSL)         

    ^                           ^              
    |                           |              
    |            +--------------+              
    |            |              |              
+---+------------+---+    +-----+------------+ 
|                    |    |                  | 
|  Main pfSense      |    |  Backup pfSense  | 
|  server            |    |  server          | 
|                    |    |                  | 
+---------+----------+    +----+-------------+ 
          | 192.168.1.1        |  
          |                    |               
          |                    |               
          |                    |               
+---------+--------------------+-------------+ 
|                                            | 
|             Ethernet switch                | 
|                                            | 
+--------------------------------------------+ 

I want to known if it is possible and where to do that (at the pfSense level or at the switch level)?


Yes, this is absolutely possible. In fact, the pfSense wiki has an entire page dedicated to this topic.

In short, you'll use CARP VIPs so to move your gateway address between routers and then use pfSense's XMLRPC sync to synchronize config between the two devices.

In an ideal setup, you'd have both of your internet circuits connected to each router. This gives you the highest degree of flexibility and resiliency, so consider changing your architecture to consider this.