CAN302 Technologies for E-Commerce
臭狗lzx看这👇
Email : Ping.Zhang@xjtlu.edu.cn
Office : EE222
Lecture 1 Introduction
Commerce: The exchange or buying and selling of commodities on a large scale involving transportation from place to place.
Business: The activity of making, buying or selling goods or providing services in exchange for money.
Definition of e-Commerce
- Electronic commerce (EC)
Electronic enabled commercial transactions between and among organizations and individuals 电子使组织和个人之间的商业交易成为可能 - Internet commerce (web commerce)
The process of buying, selling, or exchanging products, services, or information via Internet 交易:通过因特网购买、出售或交换产品、服务或信息的过程 - E-business
It in volves using information technologies in all aspects of the business.
Widely used E-business systems
只有一个是标红的: CRM (Customer Relationship Management)
Three flows in commerce
Broad definition: any process by computer (electronic) would be e-commerce.
Narrow definition: the order process should be an e-format.
Security is always the No.1 issue
EFT: eletronic fund transfer
EDI: Electronic Data Interchange
- EDI made the e-commerce beyond e-payment. EDI使电子商务超越了电子支付。
- EDI is the intercompany communication of business documents in a standard format. EDI是公司间以标准格式的商业文件通信。
- The simple definition of EDI is a standard electronic format that replaces paper-based documents such as purchase orders or invoices. EDI的简单定义是一种标准的电子格式,它取代了采购订单或发票等纸质文档。
- EDI is an old but still mainstream technology in B2B. EDI是B2B中的一种老技术,但仍然是主流技术。
Lecture 2 HTTP & Server
全是图片,去看ppt,搁着搬运没意义。
Lecture 3 dynamic HTML by server page
Dynamic webpage: frame+data
A dynamic website is the webpage on the server side where different contents are shown when assessed at different timings. 动态网站是服务器端的网页,在不同的时间评估时显示不同的内容。
CGI is an interface between Web server and program, language can be C,java
CGI program can access the data stored in database
CGI是Web服务器与程序之间的接口,语言可以是C、java
CGI程序可以访问存储在数据库中的数据
Java Servlet
- If we treat CGI as a concept, Servlet can be regard as a Java type CGI.
- While it is very different from traditional CGI by C or Perl.
- To have the dynamic Html content, programmer need to write a lot of “System.out.println()”.
Sever page
- ASP
- JSP (Java server page)
- PHP
Tomcat
The Apache Tomcat server is Java-based, open source reference implementation (RI) web application and servlet container created to run servlets and Java Server Pages (JSP) based web applications.Again, Tomcat server is a software. It can work together with Apache server. Apache Tomcat服务器是基于Java的开源参考实现(RI) web应用程序和servlet容器,用于运行基于servlet和Java server Pages (JSP)的web应用程序。同样,Tomcat服务器是一个软件。它可以与Apache服务器协同工作。
Tomcat可以加上Static web server使用
PHP
- PHP以类似的方式工作,将脚本嵌入到html代码中。
- PHP是为Web开发而优化的,可以用于通用用途(但是很少有人在Web之外使用它)。
- PHP是被广泛使用的,免费的,并且仍然活跃。
- Apache有支持PHP的扩展。
- XAMPP是所有必要软件的组合。
Database basics
- Similar to web server, database is a software.
- A database is an organized collection of structured information, or data, typically stored electronically in a computer system.
- A database is usually controlled by a database management system (DBMS). Together, the data and the DBMS, along with the applications that are associated with them, are referred to as a database system.
- We often call a certain database which is actually the name of DBMS.
- 与web服务器类似,数据库是一种软件。
- 数据库是结构化信息或数据的有组织的集合,通常以电子方式存储在计算机系统中。
- 数据库通常由数据库管理系统(DBMS)控制。数据和DBMS,以及与它们相关联的应用程序一起被称为数据库系统。
- 我们经常称某个数据库为DBMS。
SQL language
SQL is a pragramming language used by nearly all relational databases to query, manipulate, and define data, and to provide access control.
SQL是一种编程语言,几乎所有关系数据库都使用它来查询、操作和定义数据,并提供访问控制。
Transaction: ACID
- Atomicity: ensures that all operations within the work unit are completed successfully. Otherwise, the transaction is aborted at the point of failure and all the previous operation are rolled back to their former state. 原子性:确保工作单元内的所有操作都成功完成。否则,事务将在故障点中止,之前的所有操作将回滚到以前的状态。
- Consistency: ensures that the database properly changes states upon a successfully committed transaction. 一致性:确保数据库在成功提交事务时正确地更改状态。
- Isolation: enables transactions to operate independently of and transparent to each other. 允许事务独立操作,并且对彼此透明。
- Durability: ensures that the result or effect of a committed transaction persists in case of a system failure. 确保提交事务的结果或效果在系统故障时仍然存在。
Primary and foreign keys
- Primary key: ensures data is unique.
- Foreign key: ensures the reference relationship
Interaction with PHP server
By post or get, the parameters are send to the server
Apache has the build-in fucntion to receive such parameters
Lecture 4 Typical project life cycle
Research or Analysis
分析是设计之前的步骤
data sources是可以分析的内容
可以提供一个business plan
Design
可以是UX,UI,IA,IxD
UI: user interface
IxD: interaction design
IA: information architerture
UX: user experience
Design tools: Adobe XD, modao, Sketch, etc
然而,UI/UX只是设计的一部分
A product requirements document (PRD) defines the requirements of a particular product, including the product’s purpose, features, functionality, and behavior. It serves as a guide for business and technical teams to help build, launch, or market the product. 产品需求文档(PRD)定义了特定产品的需求,包括产品的用途、特性、功能和行为。它可以作为业务和技术团队帮助构建、发布或销售产品的指南。
PRD is not only the UI/UX, it should address 5 types of requirements:
- Business Requirements
- Market Requirements
- Functional Requirements
- Non-Functional Requirements
- UI/UX Requirements
Develop and Test
开发过程中不是只有coding 还有test
Test in different stage
- After the survey: write system test cases调查后:编写系统测试用例
- After design: write unit test cases设计后:编写单元测试用例
- After the module is submitted: execute the unit test case and revise it模块提交后:执行单元测试用例并修改它
- Unit test in progress: write integration test cases进行中的单元测试:编写集成测试用例
- After module assembly: execute integration test cases and revise them模块组装后:执行集成测试用例并修改
- Requirements change during development: modify all the above test cases开发过程中的需求变更:修改以上所有测试用例
- Before release: execute system test cases发布前:执行系统测试用例
Test what
- Functional test: pay attention to whether the function is correct.
- Usability test: pay attention to whether the product is easy to use.
- Compatibility test: focus on whether the product is applicable to multiple platforms.
- Reliability test: pay attention to whether the product is stable and reliable.
- Security test: pay attention to whether the product has vulnerabilities.
- Performance test: focus on whether the product can run efficiently.
Implementation or Operation
A/B test
Lecture 5 Database cluster and Cache
Servers are more powerful computer 服务器是功能更强大的电脑
只有一个服务器的话就可能会达到up-limitation
- Network
- CPU
- Memory
- Disk I/O
Separate the web server with DB server
- to handle the high con-currency flow, the wb server and DB server should be deployed individually 为了处理高并发流量,建议将wb服务器和DB服务器分开部署
- the web server and DB server should be high availability and clusters web服务器和DB服务器应该是高可用性和集群
需要有high availability,redundance is MUST对于高风险应用
Host standby,主机需要有备用。两台主机具有相同的功能,一个主机down了第二个可以顶上
VRRP
Virtual Routing Redundancy Protocol 虚拟路由冗余协议
- Two “servers” has the same configuration. 两台路由器有相同的配置
- Standby one would check the health of active one. 备用的那个会检查开放的那个的健康情况
- Once the active one is gone, the standby one would take over the network traffic. 假如启动的那个寄了,备用的就会接替上去
- A typical software for this function: keepalived
Master/Slave MySQL
- 在电商应用中,“read”是很大一部分request
- the slave DB只负责支持“read”
- 只写将适用于主DB和多个服务器支持读。“并发货币”能力将得到扩展。
Proxy the cluster
代理集群:代理会自动的选择master和slave
Data inconsistent
数据不一致
会希望两个site可以扩大可用性,client会从两个网站中取出相同的部分
假如G2没有更新他的数据,那客户就只能获取到老的数据
CAP理论
声明任何分布式数据存储只能提供以下三种保证中的两种:
- Consistency 一致性
- Every read receives the most recent write or an error.
- Availability 可用性
- Every request receives a (non-error) response, without the guarantee that it contains the most recent write. 每个请求都会收到一个(非错误)响应,但不能保证它包含最近的写入。
- Partition tolerance 分区公差
- The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes. 系统继续运行,尽管任意数量的消息被节点之间的网络丢弃(或延迟)。
怎么选择CAP
取决于不同的情况和场景:
- Read/write master database scheme 读写主数据库方案
- Delay query scheme 延迟查询方案
- Judge the active/standby non-delay scheme 判断主备无延迟方案
- Determine synchronization site scheme 确定同步站点方案
- Waiting for synchronization site scheme 等待同步站点方案
- Semi-synchronous replication scheme + waiting point 半同步复制方案+等待点
- Group replication MGR scheme 组复制MGR方案
都是图,自己看ppt。
Lecture 6 web clusters for high flow
要把web server和DB server区分开
Nginx
the king of HTTP Proxy
Nginx is a web server, can server static contents and use multi-thread to gain the high performance.
Proxy the webservers 代理web服务器
- The web should only publish one domain name to end user. web只向最终用户发布一个域名
- Nginx is a strong web server. Nginx是一个强大的web服务器
- Nginx can server the static contents. Nginx可以服务器静态内容
- Nginx set the proxy rules based on path. Nginx基于路径设置代理规则
- There are 4 (can be any number) servers for dynamic contents proxying together by nginx. 有4个(可以是任意数量)服务器,通过nginx将动态内容代理在一起
Balancing techniques
- Round robin 默认方法: the load balancer runs through the list of upstream servers in sequence
- Hash: calculates a hash that is based on teh combination of text and NGINX variables you specify
- IP HASH: the hash is based on the client’s IP address 基于客户端的IP地址进行HASH
- Least connections: compares the current number of active connections and sends the request to the server with the fewest connections. 连接数最少:比较当前活动连接数,将请求发送给连接数最少的服务器。
- Least time: combines two metrics for each server – the current number of active connections and a weighted average response time for past requests 最短时间:结合了每个服务器的两个指标——当前活动连接数和过去请求的加权平均响应时间
Cookies and session
Http is 无状态的, 一个网页需要cookie/session去保持他的状态
假如有多个后端服务器需要被使用,服务器需要share same session
redis is a choice for session sharing
Default session file in Apache
Apache store the session as a file in ‘tmp’ folder
The contents can be set by PHP code.
Proxy the webservers 代理web服务器
Shared session with Cache: all servers can get shared session from Redis
Health check: Use heath_check to make sure all backend can work properly.
HTTP and TCP
Recall the network and http
encapsulate the data: MAC addresses后面是IP addresses在后面是TCP header
LVS (linux virtual server)
- Lvs is a kernel service of Linux system
- LVS share the VIP with real severs
- LVS re-direct the request (TCP UDP) packages to real servers
- Proxy rules based on IP +ports
- Bandwith of network card would be the bottle neck
CAN302 Technologies for E-Commerce
http://chenzhengde.github.io/2023/02/22/CAN302-Technologies-for-E-Commerce/