Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-guides/kong-api-gateway.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Microservices have gained widespread adoption in the past decade, but they present their own set of challenges. Traffic control, authentication, logging, and rate limiting are essential in distributed architectures, but not easy to manage when your organization runs dozens or hundreds of APIs.

[Kong](https://konghq.com/kong/) provides an excellent solution to these problems. It's an open-source API gateway that sits between your users and backend services. By proxying requests through Kong, you can enforce standardized authentication rules, log requests and errors, and even transform data on the fly.
[Kong](https://konghq.com/kong/) provides an excellent solution to these problems. It's an open source API gateway that sits between your users and backend services. By proxying requests through Kong, you can enforce standardized authentication rules, log requests and errors, and even transform data on the fly.

Kong can be deployed to a central server, but this slows down your application because all your web requests must pass through a central location before being sent to your backing services. Fortunately, you can take advantage of [Fly's edge hosting model](https://fly.io/) to improve performance by serving Kong on Fly's globally distributed network.

Expand Down Expand Up @@ -179,7 +179,7 @@
You have a working instance of Kong deployed to Fly, but it's not useful without any [Services or Routes](https://docs.konghq.com/2.0.x/getting-started/configuring-a-service/). In this section, you'll see how to add a Service and configure rate limiting and API key authentication. Finally, you'll secure the Kong Admin API to prevent unauthorized access to your Gateway's configuration.

### Adding a Backend Service
Kong will proxy web requests it receives to any backend API you set up. To demonstrate this functionality, you'll create a new service that proxies requests to [JSON Placeholder](https://jsonplaceholder.typicode.com/). This free service returns a JSON payload similar to what you might find when connecting to a REST API.

Check warning on line 182 in app-guides/kong-api-gateway.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Consider using 'capability' or 'feature' instead of 'functionality'. Raw Output: {"message":"Consider using 'capability' or 'feature' instead of 'functionality'.","location":{"path":"app-guides/kong-api-gateway.mdx","range":{"start":{"line":182,"column":93},"end":{"line":182,"column":106}}},"severity":"INFO","code":{"value":"Fly.WordList"}}

To add JSON Placeholder's `/posts` resource as a service named `posts`, use [curl](https://curl.haxx.se/) to post it to the Kong Admin API:

Expand Down Expand Up @@ -316,6 +316,6 @@
Once your API Gateway is running again, you'll only be able to access the Admin API through `https://<your-app-name>.fly.dev/admin-api?apikey=<your-api-key>` with a valid API key.

## Conclusion
In this post, you've seen how to use Kong API Gateway to add rate limiting and API key authentication to your backend services. You've deployed Kong to Fly's distributed hosting platform to take advantage of their global network and secured your Kong Admin Portal to limit access. If you're looking to add more functionality to your gateway, be sure to [check out the Kong Plugins directory](https://docs.konghq.com/hub/).

Check warning on line 319 in app-guides/kong-api-gateway.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Consider using 'capability' or 'feature' instead of 'functionality'. Raw Output: {"message":"Consider using 'capability' or 'feature' instead of 'functionality'.","location":{"path":"app-guides/kong-api-gateway.mdx","range":{"start":{"line":319,"column":312},"end":{"line":319,"column":325}}},"severity":"INFO","code":{"value":"Fly.WordList"}}

If you have any questions about using Kong with [Fly.io](https://fly.io/), be sure to reach out so we can help you get started.
2 changes: 1 addition & 1 deletion blueprints/shared-nothing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
This was originally published as [Print on Demand](https://fly.io/blog/print-on-demand/),
and the code for that article can be found on [GitHub as fly-apps/pdf-appliance](https://github.com/fly-apps/pdf-appliance).

This architectural pattern can be applied whenever there is a minority of requests that require an outsized amount

Check warning on line 195 in blueprints/shared-nothing.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Prefer 'outsize' over 'outsized' Raw Output: {"message":"Prefer 'outsize' over 'outsized'","location":{"path":"blueprints/shared-nothing.mdx","range":{"start":{"line":195,"column":100},"end":{"line":195,"column":108}}},"severity":"WARNING","code":{"value":"proselint.Needless"}}
of resources. A second example that comes to mind: I've had requests for audio capture and transcription.

## Backups
Expand Down Expand Up @@ -279,7 +279,7 @@
so your users see something while they are waiting.
</Info>

If you go to https://smooth.fly.dev/ the server nearest to you will need to spin up the index application. And if, from there, you click on demo, a second application will be started. While you might get lucky and somebody else (or a bot) may have already started these for you, the normal case is that you will have to wait.

Check warning on line 282 in blueprints/shared-nothing.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Consider using 'click' or 'click in' instead of 'click on'. Raw Output: {"message":"Consider using 'click' or 'click in' instead of 'click on'.","location":{"path":"blueprints/shared-nothing.mdx","range":{"start":{"line":282,"column":132},"end":{"line":282,"column":140}}},"severity":"INFO","code":{"value":"Fly.WordList"}}

Since all the services that are needed to support this application are on one machine, `fly deploy` can't simply start a new machine, wait for it to start, direct traffic to it, and only then start dismantling the previous machine. Instead, each machine needs to be taken offline, have the rootfs replaced with a new image, and all of its services restarted. Once that is complete, migrations need to be run on that machine; and in my case I may have several SQLite databases that need to be upgraded. I also have each machine that comes up rsync with the primary region. And finally, I generate an operational NGINX configuration and run [nginx reload](https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/).

Expand All @@ -299,7 +299,7 @@
command.
</Info>

Now lets look at what happens when I create a new event, in a new region. I (a human) get an email, I bring up my admin UI (on an instance of the index app I mentioned above). I fill out a form for the new event. I go to a separate page and add a new region. I then go to a third form where I can review and apply the changes. This involves regenerating my map, and I need to update the NGINX configuration in every existing region. There are shortcuts I can utilize which will update files on each machine and reload the NGINX configuration, but I went that way I would need to ensure that the end result exactly matches the reproducible result that a subsequent `fly deploy` would produce. I don't need that headache, so I'm actually using `fly deploy` which can add tens of seconds to the actual deploy time.
Now lets look at what happens when I create a new event, in a new region. I (a human) get an email, I bring up my admin UI (on an instance of the index app I mentioned above). I fill out a form for the new event. I go to a separate page and add a new region. I then go to a third form where I can review and apply the changes. This involves regenerating my map, and I need to update the NGINX configuration in every existing region. There are shortcuts I can use which will update files on each machine and reload the NGINX configuration, but I went that way I would need to ensure that the end result exactly matches the reproducible result that a subsequent `fly deploy` would produce. I don't need that headache, so I'm actually using `fly deploy` which can add tens of seconds to the actual deploy time.

I started out running the various commands manually, but that grew old fast. So eventually
I invested in creating an admin UI.
Expand Down Expand Up @@ -347,7 +347,7 @@
Next up volumes. I have 9 machines with 3GB disks, and 2 machines that only need 1G each.
29GB at \$0.15 per month is \$4.35.

I have a dedicated IPv4 address in order to use ssh. This adds \$2.00 per month.

Check warning on line 350 in blueprints/shared-nothing.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Consider using 'to' instead of 'in order to'. Raw Output: {"message":"Consider using 'to' instead of 'in order to'.","location":{"path":"blueprints/shared-nothing.mdx","range":{"start":{"line":350,"column":33},"end":{"line":350,"column":44}}},"severity":"INFO","code":{"value":"Fly.WordList"}}

Outbound transfer is well under the free allowance, but for completeness I'm seeing about 16GB in North America and Europe,
which at \$0.02 per GB amounts to \$0.32. And about 0.1GB in Asia Pacific, which at \$0.04 per GB adds less than a cent,
Expand Down Expand Up @@ -437,5 +437,5 @@
## Related reading

- [Getting Started with N‑Tier Architecture](/blueprints/n-tier-architecture) A contrasting architecture pattern where state is shared across the data tier — useful for understanding when shared‑nothing *isn’t* the best fit.
- [Session Affinity (a.k.a. Sticky Sessions)](/blueprints/sticky-sessions) Focused on routing and state‑isolation patterns that often come up when you adopt a shared‑nothing approach and need to keep state local to a machine.

Check warning on line 440 in blueprints/shared-nothing.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Consider using 'or' or 'also known as' instead of 'a.k.a'. Raw Output: {"message":"Consider using 'or' or 'also known as' instead of 'a.k.a'.","location":{"path":"blueprints/shared-nothing.mdx","range":{"start":{"line":440,"column":22},"end":{"line":440,"column":27}}},"severity":"INFO","code":{"value":"Fly.WordList"}}
- [Networking](/networking) The comprehensive networking overview (private networks, Anycast, WireGuard tunnels, routing) — helpful when building globally distributed isolated nodes in a shared‐nothing architecture.
2 changes: 1 addition & 1 deletion js/frameworks/meteor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
Creating a second machine to increase service availability
Finished launching new machines
-------
NOTE: The machines for [app] have services with 'auto_stop_machines = true' that will be stopped when idling

Check failure on line 136 in js/frameworks/meteor.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 'NOTE' left in text. Raw Output: {"message":"'NOTE' left in text.","location":{"path":"js/frameworks/meteor.mdx","range":{"start":{"line":136,"column":1},"end":{"line":136,"column":5}}},"severity":"ERROR","code":{"value":"proselint.Annotations"}}

-------
Checking DNS configuration for hello-meteor.fly.dev
Expand Down Expand Up @@ -208,7 +208,7 @@

Your browser will be sent to the displayed URL.

## _Session Affinity (aka 'Sticky Sessions')_ {#session-affinity-akasticky-sessions-39}
## _Session Affinity (also known as 'Sticky Sessions')_ {#session-affinity-akasticky-sessions-39}

Sticky sessions are a feature of a load balancer that ensures that all requests from a client are routed to the same server. This can be important for Meteor applications depending on the client/server architecture of your app, as it ensures that the client is always connected to the same server, and that any changes made to the server are reflected in the client.

Expand Down
Loading