Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 1.62 KB

README.md

File metadata and controls

72 lines (51 loc) · 1.62 KB
title keywords description
Prefork
prefork
Running an application in prefork mode.

Prefork Example

Github StackBlitz

This project demonstrates how to use the Prefork feature in a Go application using the Fiber framework. Preforking can improve performance by utilizing multiple CPU cores.

Prerequisites

Ensure you have the following installed:

Setup

  1. Clone the repository:

    git clone https://github.com/gofiber/recipes.git
    cd recipes/prefork
  2. Install dependencies:

    go get

Running the Application

  1. Start the application:
    go run main.go

Example

Here is an example of how to set up the Prefork feature in a Fiber application:

package main

import (
    "log"

    "github.com/gofiber/fiber/v2"
)

func main() {
    // Fiber instance with Prefork enabled
    app := fiber.New(fiber.Config{
        Prefork: true,
    })

    // Routes
    app.Get("/", func(c *fiber.Ctx) error {
        return c.SendString("Hello, World!")
    })

    // Start server
    log.Fatal(app.Listen(":3000"))
}

References