物联网内存吃紧,跑JVM这种内存大户肯定吃不消.
要跑还是跑C实现的服务,比如Nginx+PHP+SQLite.
比如一些家用无线路由器,系统是Linux发行版OpenWrt,内存只有64MB到128MB,单核580MHz.
而PHP内置HTTP服务器和SQLite数据库,在无线路由器里对外提供HTTP服务丝毫没有问题.
交叉编译PHP也很简单:
cd /opt/miwifi/src/php-7.1.5
CC=mipsel-openwrt-linux-uclibc-gcc \
AR=mipsel-openwrt-linux-uclibc-ar \
LD=mipsel-openwrt-linux-uclibc-ld \
RANLIB=mipsel-openwrt-linux-uclibc-ranlib \
STRIP=mipsel-openwrt-linux-uclibc-strip \
./configure \
--host=mipsel-openwrt-linux-uclibc \
--prefix=/opt/miwifi/php/7.1 \
--enable-cli \
--disable-cgi \
--disable-fpm \
--disable-phpdbg \
--disable-all \
--with-sqlite3 \
--with-pdo-sqlite \
--enable-json \
--enable-session \
--enable-mbstring \
--enable-bcmath
当然了,PHP还有Swoole这种网络编程框架.