github.com/square/finch@v0.0.0-20240412205204-6530c03e2b96/docs/content/operate/client-server.md (about)

     1  ---
     2  weight: 2
     3  title: "Client/Server"
     4  ---
     5  
     6  ## Client
     7  
     8  Specify [`--client ADDR`]({{< relref "operate/command-line#--client" >}}) to run Finch as a client connected to the server at `ADDR`.
     9  
    10  A client ignores other [command line options]({{< relref "operate/command-line#command-line-options" >}}) and automatically receives stage and trx files from the server.
    11  
    12  The client runs only once.
    13  This is largely due to https://bugs.mysql.com/bug.php?id=110941: MySQL doesn't properly terminate clients/connections in some cases, especially when the client aborts the connection, which is what the Go MySQL driver does on context cancellation.
    14  
    15  ## Server
    16  
    17  Specify [`--server ADDR`]({{< relref "operate/command-line#--server" >}}) to run Finch as a server that listens on ADDR[:PORT} for remote compute instances.
    18  
    19  The recommended client-server startup sequence is server then clients: start the server, then start the clients.
    20  
    21  The server is counted as one compute instance called "local".
    22  Set [`stage.compute.disable-local`]({{< relref "syntax/stage-file#disable-local" >}}) to disable.
    23  
    24  {{< hint type=note >}}
    25  A standalone instance of Finch is a pseduo-server that doesn't bind to an interface and runs only locally.
    26  As a result, [`--debug`]({{< relref "operate/command-line#--debug" >}}) prints server info even when `--server` is not specififed.
    27  {{< /hint >}}
    28  
    29  ## Protocol
    30  
    31  The client-server protocol is initiated by clients over a standard HTTP port.
    32  The server needs to allow incoming HTTP on that port (default 33075).
    33  
    34  {{< mermaid class="text-center" >}}
    35  sequenceDiagram
    36      autonumber
    37  
    38      activate client
    39      client->>server: GET /boot
    40      server-->>client: return stage files
    41  
    42      loop Every trx file
    43          client->>server: GET /file?trx=N
    44          server-->>client: return trx file N
    45      end
    46      
    47      client->>server: POST /boot
    48      server-->>client: ack
    49      
    50      client->>server: GET /run
    51      deactivate client
    52      Note over client: Client waits for server
    53      Note over server: Server waits for stage.compute.instances
    54  
    55      server-->>client: ack
    56      
    57      activate client
    58      Note left of client: Client runs stages
    59      loop While running
    60          client->>server: POST /stats
    61          server-->>client: ack
    62      end
    63      deactivate client
    64      
    65      Note left of client: Client done running
    66      client->>server: POST /run
    67      server-->>client: ack
    68  {{< /mermaid >}}