内容简介:An ongoing experiment usingSo far using a thread pool and channels to communicate with the Warp route handler. The goal is to get a full Node-likeNode outperforms QuickJS by a wide margin. Especially with enough cores and memory. However, QuickJS is very s
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 install -
npm test
Or npm run build
for generating the Rust binary.
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
算法导论(原书第2版)
[美] Thomas H.Cormen、Charles E.Leiserson、Ronald L.Rivest、Clifford Stein / 潘金贵 等 / 机械工业出版社 / 2006-9 / 85.00元
这本书深入浅出,全面地介绍了计算机算法。对每一个算法的分析既易于理解又十分有趣,并保持了数学严谨性。本书的设计目标全面,适用于多种用途。涵盖的内容有:算法在计算中的作用,概率分析和随机算法的介绍。书中专门讨论了线性规划,介绍了动态规划的两个应用,随机化和线性规划技术的近似算法等,还有有关递归求解、快速排序中用到的划分方法与期望线性时间顺序统计算法,以及对贪心算法元素的讨论。此书还介绍了对强连通子图......一起来看看 《算法导论(原书第2版)》 这本书的介绍吧!