Translate

Hiển thị các bài đăng có nhãn Server/WebServer. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Server/WebServer. Hiển thị tất cả bài đăng

Thứ Năm, 6 tháng 11, 2014

Giao thức giao tiếp client - server

Remoting Retrospective: DCE, COM, CORBA, RMI, RMI/IIOP, SOAP, REST, WebSockets

Use-cases

SOAP
  • enterprise
  • service description
  • static typing
  • end-to-end security
  • third-party authentication
  • interoperability
REST
  • public APIs
  • small footprint
  • loose-coupling
  • interoperability
WebSockets
  • browsers as universal clients for event oriented apps (full duplex low latency)
  • multiplayer games, chat, live tickers (e.g., sport/stock), social streams
  • service push; pub/sub
  • alternative to AJAX, Comet, long polling, HTML5/SSE, …
  • async, frame-oriented and state-oriented app protocols layered on top
  • e.g. AMQP, XMPP, JMS, STOMP, VNC (RFB),
  • private subprotocols (e.g., small, binary)
  • potential performance improvement
  • tight-coupling
Timeline details
  • HTTP
  • strict request-response model
  • client sends request, waits until response received

  • AJAX/XMLHttpRequest
  • pulls data "requests" from server
  • XMLHttpRequest just does HTTP request in background (no UI blockage) with callback handling response
  • polling: apps periodically do AJAX request to ask if server has an "event"
  • event latency depends on polling period
  • can increase polling rate
  • but wastes resources and scales poorly (most polls return empty)


  • COMET/LONG-POLLING ("reverse AJAX")
  • client does request; service maintains connection
  • fakes notifications by sending "event"/response when ready
  • then client send request again, and wait for next event
  • always a pending request


  • HTTP STREAMING
  • service keeps response message open
  • response body never closed after sending event
  • new events written to same stream
  • response message body represents a unidirectional event stream to the client
  • requires proxies to forward "partial" responses


  • HTML5 SERVER-SENT EVENTS (SSE)
  • standardizes COMET
  • client API to open HTTP conn for receiving push notification
  • EventSource represents client endpoint to receive events
  • mime text/event-stream for event framing format
  • EventSource impl can do connection management to share connections
  • period reconnections under the covers
  • service should send periodic "keep-alive" comments
  • to avoid proxies killing the connection


  • WebSockets
  • server can send info to client anytime: update latency reduced
  • server handles fewer connection requests
  • some requests transformed into updates to WebSockets
  • but then connection management
  • client heartbeats be required so server can cleanup dead connections
  • service heartbeat not required
  • service pushes shows it is alive
  • but might need to reset connection if no updates
  • support WebSockets but fall back to HTTP Streaming and HTTP Long Polling dynamically
  • no connection reliability
  • no reconnect handling
  • no guaranteed message delivery (like Server-Sent Event does)
  • reliability has to be in app (same as "keep alive" message in SSE)
  • sharing WebSocket between different pages must lock writes/reads
  • no same origin policy limitation
  • enabling siloed apps

SOAP/WebSocket potential benefits
  • can tunnel out of a firewall
  • use instead of WS-MakeConnection
  • connection-based
  • use instead of WS-ReliableMessaging
  • multi-message communication
REST/WebSockets potential benefits
  • multi-message communication
  • existing apps use REST/WebSockets lib
  • reduced overhead of single connection without refactoring code
  • Transactional-REST
  • beginTransaction; REST/WebSocket calls, … ; endTransaction;
  • if connection drops before commit then rollback TX


Ref:
https://weblogs.java.net/blog/haroldcarr/archive/2012/10/02/soap-andor-rest-andor-websockets

Thứ Năm, 5 tháng 6, 2014

SSH and Rsync within Cygwin (Unix - Windows)

This post documents the steps I have used to setup SSH and Rsync within a Cygwin Windows environment.

Cygwin Setup
This is not an in-depth guide for installing Cygwin; although, installing Cygwin is a fairly simple process. In or to implement SSH and rsync functionality, a few non-default Cygwin packages will need to be installed.
  1. Download and run the Cygwin setup.exe program from http://cygwin.com/install.html
    If you already have Cygwin installed, that should not be a problem. You can still run setup.exe to install additional Cygwin packages.
  2. Proceed through the Cygwin setup process until you get to the "Select Packages" screen. From there, make sure the following packages are selected:
    • Net -> openssh
    • Net -> rsync
    • Admin -> cygrunsrv
    • Editors -> nano (optional, but I find it to be a very simple text editor to use in place of vi or emacs)
    • Web -> wget (optional, but useful for downloading files without a browser)
  3. Finish the Cygwin setup wizard allowing the selected packages, including any required dependency packages, to be installed.

Thứ Hai, 2 tháng 6, 2014

Tăng tốc độ mạng sử dụng đồng thời 2 đường kết nối USB 3G trên một PC/Tablet/SmartPhone

Thử hình dung TH bạn mang laptop đi xa, cần kết nối internet mạnh nhưng mạng 3G ở đó yếu nên cần sử dụng 2 USB 3G của 2 nhà cung cấp khác nhau (ví dụ Viettel, Vinaphone) để tăng tốc thì làm thế nào? 
Ngoài ra có những TH bạn cần truyền file có size lớn bằng tốc độ nhanh nhất có thể nên muốn chia file ra để truyền trên 2 đường khác nhau.
Pro hơn nữa bạn muốn gộp băng thông đang có của 2 nhà cung cấp khác nhau thành 1 đường mạng mạnh ổn định cho riêng bạn.

Vậy có làm được không? Làm thế nào?
Câu trả lời là làm được. Trên nền Linux cơ bản bạn hãy nghiên cứu sử dụng iproute, trên Win bạn thử nghiên cứu giao thức Multi-path TCP nhé.

Thứ Bảy, 24 tháng 5, 2014

Batch Script chạy Code Coverage report cho Android app

Trong mô hình phát triển ứng dụng mới theo kiểu TDD (Test driven) hay CI (Continuous Integration) thì việc đảm bảo code luôn chạy chuẩn thông qua Unit Test là rất quan trọng. Tuy nhiên một trong những vấn đề nổi cộm là developer rất lười viết Unit Test, hoặc viết một cách đối phó nên chất lượng không tốt.

Vậy làm thế nào để bạn đảm bảo team của mình đã viết Unit Test đầy đủ và có ích?

Một trong các giải pháp là hãy kiểm tra Code Coverage (nghĩa là unit test case đã coverage được bao nhiêu phần trăm method, line of code trong source code của app) bằng các tool/plugin có sẵn.

Thứ Hai, 19 tháng 5, 2014

Các lệnh và module thường dùng trong Linux

This article provides practical examples for 50 most frequently used commands in Linux / UNIX.
This is not a comprehensive list by any means, but this should give you a jumpstart on some of the common Linux commands. Bookmark this article for your future reference.

Did I miss any frequently used Linux commands? Leave a comment and let me know.

Lập lịch định kỳ thực hiện task trong Window và Linux

Trong Linux dùng crontab để chạy các bash script (sh).
http://tecadmin.net/crontab-in-linux-with-20-examples-of-cron-schedule/#

Trong Window ví dụ Win Server 2K8 dùng Task Scheduler để chạy các file batch (bat).
http://www.windowsnetworking.com/articles-tutorials/windows-server-2008/Working-Windows-Server-2008-Task-Scheduler-Part1.html

Đồng bộ hóa file (sync data) trong Linux

Sử dụng lệnh rsync của Linux để đồng bộ hóa file dữ liệu giữa 2 directory của Linux và Window với các option khác nhau. 

rsync is a free software computer program for Unix and Linux like systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction.

http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/


Thiết lập gửi mail trong server Linux

1. Gửi mail như 1 máy PC cá nhân dùng gmail để gửi
2. Nhận mail như nhận gmail bằng Outlook trên máy PC cá nhân
3. Thiết lập máy server như một mail server

Chia sẻ file giữa Windows và Linux (Samba, NFS, CIFS)

Chia sẻ file giữa hệ điều hành Windows và Linux theo nhiều cách.


Ứng dụng: Trong chia sẻ file thông thường giữa 2 máy tính cá nhân hoặc tự động truyền file giữa 2 server Windows và Linux. Có 3 giao thức chính là Samba, NFS và CIFS.

Chủ Nhật, 18 tháng 5, 2014

Mô hình phát triển Continuous Integration với Jenkins

This article describes how to build a continuous integration cycle for Java development with the Jenkins continuous integration build server.

1. Continuous Integration with Jenkins

1.1. Continuous Integration Overview

Continuous integration is a process in which all development work is integrated at a predefined time or event and the resulting work is automatically tested and built. The idea is that development errors are identified very early in the process.

1.2. Jenkins

Jenkins is one open source tool to perform continuous integration. The basic functionality of Jenkins is to monitor a version control system and to start and monitor a build system (for example, Apache Ant or Maven) if changes occur. Jenkins monitors the whole build process and provides reports and notifications to alert maintainers on success or errors.
Jenkins can be extended by additional plug-ins, e.g., for building and testing Android applications.

Thứ Tư, 19 tháng 3, 2014

Fiddler - mô phỏng mạng chậm hoặc bắt gói tin HTTPS

Fiddler (http://www.telerik.com/fiddler) là một công cụ có công dụng được mô tả:
"Free web debugging proxy for any browser, system or platform."

Có nhiều chức năng nhưng ở đây mình chỉ mô tả 2 chức năng đã dùng:
1. Mô phỏng truy cập mạng chậm ví dụ tốc độ 54kb/s (DSL Modem) hay 1Mb/s (ADSL).

Để thực hiện, hãy cài Fiddler lên PC rồi vào mục Rules/Customize Rules và sửa thời gian delay ở mục m_SimulatedModem. Ví dụ: tốc độ 256kb/s thì sửa delay time thành 4000ms, tốc độ 1Mb/s thì sửa thành 1000ms.
Sau đó khi khởi động lại Fiddler thì vào mục Tool/Rules/Performance/Simulate Modem Speeds.

Kết quả:
Sau đó bạn vào browser mở 1 trang web bất kỳ, nó sẽ được truy cập (up/down) ở tốc độ mạng mà bạn thiết đặt.

Thứ Bảy, 1 tháng 3, 2014

Xử lý các tính huống thực tế với WireShark

A. Xử lý các tình huống về băng thông mạng

Anatomy of a Slow Download (cốt lõi của việc download chậm)
Tình huống: cả mạng download rất chậm
Tiến hành : đặt wireshark lắng nghe toàn bộ đầu ra của mạng
Phân thích : hình ảnh dưới đây cho thấy có rất nhiều kết nối TCP,HTTP điều này có nghĩa là có rất nhiều kết nối HTTP download dữ liệu về nên chiếm băng thông của mạng.

Phân tích gói tin với WIRESHARK

Giới thiệu qua một chút về Wireshark


- WireShark có một bề dầy lịch sử. Gerald Combs là người đầu tiên phát triển phần mềm này. Phiên bản đầu tiên được gọi là Ethereal được phát hành năm 1998. Tám năm sau kể từ khi phiên bản đầu tiên ra đời, Combs từ bỏ công việc hiện tại để theo đuổi một cơ hội nghề nghiệp khác. Thật không may, tại thời điểm đó, ông không thể đạt được thoả thuận với công ty đã thuê ông về việc bản quyền của thương hiệu Ethereal. Thay vào đó, Combs và phần còn lại của đội phát triển đã xây dựng một thương hiệu mới cho sản phẩm “Ethereal” vào năm 2006, dự án tên là WireShark.
- WireShark đã phát triển mạnh mẽ và đến nay, nhóm phát triển cho đến nay đã lên tới 500 cộng tác viên. Sản phẩm đã tồn tại dưới cái tên Ethereal không được phát triển thêm.
- Lợi ích Wireshark đem lại đã giúp cho nó trở nên phổ biến như hiện nay. Nó có thể đáp ứng nhu cầu của cả các nhà phân tích chuyên nghiệp và nghiệp dư và nó đưa ra nhiều tính năng để thu hút mỗi đối tượng khác nhau.


Bảo mật SSH với chứng thực khóa công khai / khóa riêng

SSH là một công cụ tuyệt vời, không một quản trị hệ thống nào có thể bỏ qua. Sử dụng SSH bạn có thể kết nối tới máy chủ và làm tất cả mọi việc với no.
Bài viết này tôi tập trung vào việc giới thiệu : làm sao tạo và sử dụng Public/Private key trong truy cập qua giao thức SSH.
Đây là kỹ thuật khá cơ bản nhưng tỏ ra cực kỳ hiệu quả, mang lại sự an toàn cao đối với hệ thống của bạn.
Sử dụng Public/Private key authentification bạn có thể tránh được:
- tấn công dò mật khẩu (bruce password scan)
- bảo vệ mật khẩu root

Trong các bản phân phối hiện nay hầu hết đều được tích hợp sẵn OpenSSH. Phiên bản SSH hiện nay là SSH2. SSH2 khác nhiều so với SSH1 và an toàn hơn.

Thứ Năm, 20 tháng 2, 2014

Phân tích hay về Phalcon Framework

Đầu năm 2013, nhu cầu khách hàng phát triển ứng dụng di động tăng kèm theo là yêu cầu phát triển cả phần server tập trung hóa dữ liệu. Về cơ bản đây không khác nhiều với mô hình client – server truyền thống, ngoại trừ, server thường phải host trên Internet thay vì mạng LAN, ứng dụng không trực tiếp kết nối vào CSDL mà gọi đến REST web service để gửi nhận dữ liệu định dạng JSON. Điểm khác biệt lớn nhất của ứng dụng di động kết nối server là số lượng người dùng đồng thời khá lớn, đôi khi có thể tăng vọt ở một số thời điểm trong ngày, tuần hoặc các sự kiện. Ngoài ra do sức ép cạnh tranh giá cả, việc phát triển ứng dụng web + web service cần phải nhanh, tốn ít công, hiệu suất lập trình cao, đáp ứng tải (concurrent load) tốt với điều kiện máy chủ hosting không được quá đắt là yếu tố sống còn.

Chủ Nhật, 15 tháng 12, 2013

Security issue by injecting JavaScript into a WebView

Recently we have been researching vulnerabilities within cross platform mobile application development frameworks. Whilst performing this research we have identified a number of issues. The advisory details one of the more serious of the issues, which affects all current Android platforms and devices. The issue allows an attacker to execute arbitrary code on Android devices. The vulnerability is exploited by injecting JavaScript into a WebView). We have released output from related research previously; see the previous post Adventures With Android WebViews for background information.

Thứ Bảy, 2 tháng 11, 2013

The ridiculous case of adding a script element

Adding a script element to a page should be a no-brainer. Yet, it's ridiculously unreliable in the wild - when you don't have any idea of the surrounding markup.
You know the drill - create a script element, point its src to a URL and add it to the page so that script file can be downloaded in a non-blocking manner.
Creating the script is nice and easy:
var js = document.createElement('script');
js.src = 'myscript.js';
The problem is how to add it to the page?

Thứ Hai, 26 tháng 8, 2013

Cài đặt XAMPP, Memcache, Redis, Debug PHP trên Windows 7 64bit

Hướng dẫn cài đặt lập trình ứng dụng PHP có sử dụng cache trên nền Windows sử dụng bộ XAMPP.
1. XAMPP
Cài xampp-win32-1.8.2-1-VC9-installer.exe vào ổ C:\
Trong bộ này đã có MySQL, PHP 5.4, phpMyAdmin.  Sau khi cài xong vào XAMPP Control Panel để start Apache và MySQL. Nếu gặp lỗi không start được Apache thì có thể do xung đột port mà apache dùng (80, 443) vì vậy vào mục Config sửa 2 file httpd.conf và httpd-ssl.conf sang dùng port khác rồi khởi động lại (ví dụ port 1234, 1235).

2. Redis
Cài redis-2.4.6-setup-64-bit.exe vào win sẽ có redis client và redis server, kiểm tra bằng cách vào redis client gõ ping, nếu redis server trả lời pong là OK.
Muốn PHP sử dụng được redis thì phải copy php_redis.dll và php_igbinary.dll vào thư mục ext của php trong thư mục XAMPP và thêm dòng sau vào file php.ini:
extension=php_igbinary.dll
extension=php_redis.dll
Lưu ý phải tìm down phiên bản php_redis.dll được biên dịch phù hợp (cùng version) với phiên bản Php 5.4 đang chạy.

Thứ Hai, 12 tháng 8, 2013

C# - Cơ chế yielding và ‘yield’ keyword trong Iteration

“yield” – Một từ khóa có vẻ lạ lẫm với bạn nhưng đã được ứng dụng từ lâu trong lĩnh vực lập trình và trong khá nhiều ngôn ngữ. Từ khóa này gắn liền với các kĩ thuật như Generator, Coroutine và các đối tượng iterator. Ta sẽ khám phá cơ chế và cách sử dụng của từ khóa này như thế nào.

Giới thiệu

Theo MSDN:
The yield keyword signals to the compiler that the method in which it appears is an iterator block. The compiler generates a class to implement the behavior that is expressed in the iterator block. In the iterator block, the yield keyword is used together with the return keyword to provide a value to the enumerator object. This is the value that is returned, for example, in each loop of a foreach statement. The yield keyword is also used with break to signal the end of iteration.

Chủ Nhật, 11 tháng 8, 2013

Cơ bản Asp.NET MVC4

ASP.NET MVC4 là framework tạo website theo mô hình MVC, phiên bản MVC4 có 1 số cải tiến tinh gọn so với phiên bản MVC3 tuy nhiên ở đây ta sẽ coi như không biết gì về Asp.Net MVC3 và bắt đầu hoàn toàn từ đầu với các khái niệm của Asp.NET MVC4.

Sau khi thử nghiệm tạo ứng dụng MVCMovie có 1 số điểm note lại: