Translate

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

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

Thứ Bảy, 26 tháng 7, 2014

Six Ways to Get Excellent Software Outsourcing Results

You have probably heard the stories.
Software that does not work. Software that does the wrong thing. Money paid to set up an offshore team that never produces any software. Can these outsourcing nightmares be avoided?
Of course, but it takes good management of your outsourcing. Whether you’re outsourcing to India orArgentina, location isn’t as important as effectively managing your team to promote innovation and make your project a success.
The two biggest fears of outsourcing that I hear from prospects and clients are the fear of selecting a bad outsourcing partner and the fear of not managing their work effectively. Let’s assume you pick a great team. Even then you may still have lingering worries about getting your software developed quickly.
Here are six strategies you can implement to effectively manage your outsourcing and get reliable results.

Chủ Nhật, 13 tháng 7, 2014

Using Google Cloud to predict result of WorldCup football match

Using Google Cloud to predict result of WorldCup football match.
Very fun and good reference on BigData and GoogleCloud service!

Article:
http://googleblog.blogspot.com/2014/07/google-cloud-platform-predicts-world.html
http://googlecloudplatform.blogspot.com/2014/07/we-think-germany-will-win-but-dont-take-our-word-for-it.html

Guideline:
http://nbviewer.ipython.org/github/GoogleCloudPlatform/ipython-soccer-predictions/blob/master/predict/wc-final.ipynb


Source code:
https://github.com/GoogleCloudPlatform/ipython-soccer-predictions


Thứ Năm, 10 tháng 7, 2014

Android storage option

Có nhiều khái niệm về các loại phương tiện lưu trữ và các lựa chọn lưu trữ trong ứng dụng Android mà chúng ta có thể chưa phân biệt rõ hay nhầm lẫn khi phát triển ứng dụng. Dưới đây liệt kê một số phương tiện và lựa chọn lưu trữ.

Option lưu trữ:
Trong Android có 3 loại chính:
1. USB storage (Internal storage trong thiết bị Android, kèm khi xuất xưởng)
2. SD-Card (External storage cắm vào thiết bị Android)
3. App-Private storage (ví dụ SharedPref, DB, Cache, là 1 loại Internal storage)

Phương tiện lưu trữ:
1. USB mass storage
2. Thẻ nhớ SD-Card
3. Thiết bị phát dữ liệu, cắm vào cổng USB của thiết bị chạy Android (ví dụ máy MP3)

Các thiết bị này được cắm vào thiết bị Android mobile (thông qua dây USB OTG) hoặc cắm trực tiếp vào cổng USB của thiết bị chạy Android chẳng hạn như TV.

USB khác SD-Card như nào?
Cơ bản mình cho là trường hợp USB cắm vào Android Mobile thì USB lúc này được coi là SD-Card.

Nếu phân biệt rõ những option và phương tiện này thì lúc lập trình và tìm kiếm các intent tương ứng sẽ chính xác.

Link tham khảo chính:
http://developer.android.com/guide/topics/data/data-storage.html

Link phụ:
http://developer.android.com/guide/topics/connectivity/usb/host.html#example
http://androidforums.com/android-lounge/432740-usb-storage-sd-card-storage.html

http://alvinalexander.com/java/jwarehouse/android/services/java/com/android/server/status/UsbStorageActivity.java.shtml




Thứ Tư, 18 tháng 6, 2014

19 trang web khiến bạn sử dụng thời gian trực tuyến hiệu quả hơn

Sau đây là danh sách 19 trang web thực sự sẽ khiến bạn sử dụng thời gian trực tuyến của mình hiệu quả và thông mình hơn.

Bỏ Facebook đi, 19 trang web này sẽ giúp bạn thông minh hơn!