backgroundradial

Introducing MySQL & Postgres support for PHP in Wasmer Edge

syrusakbary avatar
syrusakbary

Founder & CEO

edge

July 23, 2024

arrowBack to articles
Post cover image

Today we are releasing the biggest update for PHP in Wasmer and Wasmer Edge: MySQL and Postgres clients are now fully supported (via the mysqli and pgo PHP extension).

As part of having a renewed PHP we also added support for the most popular PHP extensions: gd, session, ctype, dom, hash, simplexml, json, gd, mbstring, xml, tidy, iconv, curl, gettext, tokenizer, bcmath, mysqli, pgo, pdo...

This means that you can use almost any PHP program out there and persist the state of your PHP application easily using external databases. Just use the php/php@8.3.400 package and get ready to get rolling!

You can now create a database in any of the popular serverless database providers: Supabase, PlanetScale, Neon, Xata and TiDB Cloud - and use them as usual in your Wasmer Edge PHP apps.

In previous announcements, we showcased using Wordpress at the Edge with SQLite. However, this approach had one downside: SQLite was using an in-memory filesystem, so any changes you made were not persisted at all.

Thanks to support connecting to external databases, along with the support for secrets in Wasmer Edge announced a few days ago, you can now securely connect into MySQL and Postgres databases from Wasmer Edge.

We have set up a sample Wordpress example using PlanetScale here (see source code):

https://wordpress-planetscale-wasmer-examples.wasmer.app/

Measuring DB latency

Following good practices from Serverless providers, we have created a database benchmark measuring different DBs performance with Wasmer Edge.

You can now easily analyze the performance of your favorite providers on Wasmer Edge:

db-latency.wasmer.app

Wasmer Edge Database Latency website screenshot

Improving latency at the Edge with Region pinning

After analyzing the latency for apps that used databases, we realized that in most cases, the most performant strategy is to pin the Edge location close to the database.

As part of performance optimization, we added support for region pinning, so you can now pin your edge app into a specific location(s):

locality:
  regions:
  - us-ashburn

Note: many more regions are supported, check the Wasmer docs to see which region could be more convenient to improve database latency: https://docs.wasmer.io/edge/learn/regions


Join Us on the Edge of Innovation

You can now use external databases in your PHP applications. Many other languages already support connecting to your external DBs (Rust, Python).

At Wasmer we are working incredibly hard to enable your use cases in the Edge. Do you have a use case that we don’t currently support? Please join our Discord and let us know!

For more information visit Wasmer Edge documentation.

Lets keep our apps shining! ✨

About the Author

Syrus Akbary is an enterpreneur and programmer. Specifically known for his contributions to the field of WebAssembly. He is the Founder and CEO of Wasmer, an innovative company that focuses on creating developer tools and infrastructure for running Wasm

 avatar

Founder & CEO

Read more
Post cover image

wasmerwasmer edgerustprojectsedgeweb scraper

Build a Web Scraper in Rust and Deploy to Wasmer Edge

RudraAugust 14, 2023

wasmer edgeedgekubernetesdocker

The Rise of the Monolith

November 28, 2023

runtimeedgesinglepass

Announcing Wasmer 4.3.0

May 10, 2024