galvez/fast-vue-ssr
关于
Fast Vue SSR experiment with QuickJS and Rust
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Fast Vue SSR with Rust and QuickJS
An ongoing experiment using Rust, Warp and QuickJS to server-side render Vue.js applications.
use renderer::RendererPool;
#[tokio::main]
pub async fn main() -> io::Result<()> {
let pool = Arc::new(Mutex::new(RendererPool::new(64)));
let renderer = warp::path::full().map(move |path: FullPath| {
let renderer = Arc::clone(&pool);
let s = path.as_str().to_string();
// Currently only passing path to renderer is possible
// Full Request object is a WIP
let result = renderer.lock().unwrap().render(s);
result
});
let routes = warp::path::full()
.and(renderer)
.map(|_, result| reply::html(result));
So far using a thread pool and channels to communicate with the Warp route handler. The goal is to get a full Node-like IncomingMessage object available as $ssrContext.req. It already includes a /static handler and serves a code-splitted build on the client via Rollup.
Node outperforms QuickJS by a wide margin. Especially with enough cores and memory. However, QuickJS is very small and has very low memory consumption, so running it threaded in a Rust shell makes it possible to have very high throughput using very few resources in comparison.
Inspired by Xinjiang Shao's experiment.
Running
- Install Rust.
npm installnpm test
Or npm run build for generating the Rust binary.
探索相关项目
加载中…